(Created page with "local p = {} local w_frame = require( 'module:frame' ) local w_table = require( 'module:table' ) function p.parse( f ) return w_table.key( mw.loadData( 'module:dlc/data' )...") |
mNo edit summary |
||
(20 intermediate revisions by the same user not shown) | |||
Line 1: | Line 1: | ||
local p = {} |
local p = {} |
||
⚫ | |||
local w_frame = require( 'module:frame' ) |
local w_frame = require( 'module:frame' ) |
||
+ | |||
⚫ | |||
+ | local data = mw.loadData( 'module:dlc/data' ) |
||
function p.parse( f ) |
function p.parse( f ) |
||
− | return |
+ | return data.values[w_frame.args( f )[1] or ''] or 0 |
+ | end |
||
+ | |||
+ | |||
+ | function p.test( f ) |
||
+ | local args = w_frame.args( f ) |
||
⚫ | |||
end |
end |
||
− | function |
+ | function p.find( f ) |
− | local |
+ | local args = w_frame.args( f ) |
+ | local filter = args[2] == 'last' and 8 or args[2] or tonumber( mw.getCurrentFrame():callParserFunction( '#var:context' ) ) or 15 |
||
⚫ | |||
+ | local parts |
||
+ | for str in mw.text.gsplit( args[1], '▼' ) do |
||
+ | parts = mw.text.split( str, '►' ) |
||
+ | if w_bit['and']{ parts[1], filter } > 0 then |
||
+ | return parts[2] |
||
+ | end |
||
+ | end |
||
end |
end |
||
Revision as of 10:07, 3 May 2021
local p = {}
local w_bit = require( 'module:bit' )
local w_frame = require( 'module:frame' )
local data = mw.loadData( 'module:dlc/data' )
function p.parse( f )
return data.values[w_frame.args( f )[1] or ''] or 0
end
function p.test( f )
local args = w_frame.args( f )
return ( data.test[tonumber( args[1] )] or {} )[tonumber( args[2] ) or 15] or 0
end
function p.find( f )
local args = w_frame.args( f )
local filter = args[2] == 'last' and 8 or args[2] or tonumber( mw.getCurrentFrame():callParserFunction( '#var:context' ) ) or 15
local parts
for str in mw.text.gsplit( args[1], '▼' ) do
parts = mw.text.split( str, '►' )
if w_bit['and']{ parts[1], filter } > 0 then
return parts[2]
end
end
end
return p