m (Test) |
mNo edit summary |
||
(11 intermediate revisions by the same user not shown) | |||
Line 1: | Line 1: | ||
local p = {} |
local p = {} |
||
− | + | local bit32 = require( 'bit32' ) |
|
+ | |||
local w_frame = require( 'module:frame' ) |
local w_frame = require( 'module:frame' ) |
||
+ | |||
local data = mw.loadData( 'module:dlc/data' ) |
local data = mw.loadData( 'module:dlc/data' ) |
||
function p.parse( f ) |
function p.parse( f ) |
||
− | p.x = p.x + 1 |
||
return data.values[w_frame.args( f )[1] or ''] or 0 |
return data.values[w_frame.args( f )[1] or ''] or 0 |
||
end |
end |
||
+ | function p.test( f ) |
||
− | p.x = 10 |
||
− | + | local args = w_frame.args( f ) |
|
⚫ | |||
− | return p.x |
||
end |
end |
||
− | function p. |
+ | function p.find( f ) |
− | local args = w_frame.args( 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, '►' ) |
||
− | local context = args[2] |
||
+ | if bit32.band( parts[1], filter ) > 0 then |
||
− | |||
⚫ | |||
− | if context == 15 then |
||
⚫ | |||
⚫ | |||
⚫ | |||
− | |||
− | local filtered = w_bit['and']{ value, context } |
||
− | if filtered == 0 then |
||
− | return 0 |
||
− | end |
||
− | |||
− | if w_bit['or']{ value, context } == value then |
||
− | return 15 |
||
− | end |
||
− | |||
− | local limits = w_bit['and']{ 9, filtered } |
||
− | if limits == value then |
||
− | return limits |
||
end |
end |
||
− | ]] |
||
end |
end |
||
Revision as of 16:15, 29 August 2021
local p = {}
local bit32 = require( 'bit32' )
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 bit32.band( parts[1], filter ) > 0 then
return parts[2]
end
end
end
return p