Binding of Isaac: Rebirth Wiki
Binding of Isaac: Rebirth Wiki
m
m
Line 43: Line 43:
 
local context = mw.getCurrentFrame():callParserFunction( '#var:context' )
 
local context = mw.getCurrentFrame():callParserFunction( '#var:context' )
 
return data.test[filter][tonumber( context ~= '' and mw.text.split( context, ' ' )[1] ) or 15] or 0
 
return data.test[filter][tonumber( context ~= '' and mw.text.split( context, ' ' )[1] ) 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 mw.getCurrentFrame():callParserFunction( '#var:context' )
  +
local parts
  +
for str in mw.text.gsplit( args[1], '▼' ) do
  +
parts = mw.text.split( str, '►' )
  +
if bit32.band( tonumber( parts[1] ), filter ) > 0 then
  +
return parts[2]
  +
end
  +
end
 
end
 
end
   

Revision as of 08:58, 3 May 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


p['context push'] = function ( f )
	local args   = w_frame.args( f )
	local filter = args.parsed or data.values[args[1]]
	if not filter then
		return
	end
	local frame   = mw.getCurrentFrame()
	local context = frame:callParserFunction( '#var:context' )
	filter = bit32.band( filter, tonumber( context ~= '' and mw.text.split( context, ' ' )[1] or 15 ) )
	if not filter then
		return
	end
	frame:callParserFunction( '#vardefine:context', filter .. ' ' .. context )
end


p['context test'] = function ( f )
	local args   = w_frame.args( f )
	local filter = tonumber( args.parsed or data.values[args[1]] )
	if not filter or not data.test[filter] then
		return 0
	end
	local context = mw.getCurrentFrame():callParserFunction( '#var:context' )
	return data.test[filter][tonumber( context ~= '' and mw.text.split( context, ' ' )[1] ) 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 mw.getCurrentFrame():callParserFunction( '#var:context' )
	local parts
	for str in mw.text.gsplit( args[1], '▼' ) do
		parts = mw.text.split( str, '►' )
		if bit32.band( tonumber( parts[1] ), filter ) > 0 then
			return parts[2]
		end
	end
end


return p