Module:EffectReference
Jump to navigation
Jump to search
Helper module to call Template:EffectReference for multiple effects at once.
It uses the same arguments as the Template, but instead of defining an effect
, you provide the effects as unnamed arguments.
For example, {{#invoke:EffectReference|main|type=PlayerInflicts|buildup=33|show=yes|Chill|Curse}}
to define a reference to Chill and Curse, and show them both.
The above documentation is transcluded from Module:EffectReference/doc. (edit | history)
local p = {}
function p.main(frame)
if frame == mw.getCurrentFrame() then
args = require('Module:ProcessArgs').merge(true)
else
frame = mw.getCurrentFrame()
end
-- iterate all unnamed arguments of the frame by using ipairs(args) and storing into a table
-- this allows us to define an unlimited number of actions, without having to worry about how many there are.
local iArgs = {}
for k, v in ipairs(args) do
iArgs[k] = v
end
if (#iArgs < 1) then
return
end
local html = mw.html.create()
local contentText = ''
-- iterate over our ipairs (args) table
for i = 1, #iArgs, 1 do
contentText = contentText .. '{{EffectReference|effect=' .. iArgs[i] .. '|type=' .. args.type
contentText = contentText .. '|effectlevel=' .. (args.effectlevel or args.level or '') .. '|buildup=' .. (args.buildup or '')
contentText = contentText .. '|chance=' .. (args.chance or '') .. '|show=' .. (args.show or '') .. '}}'
end
html:wikitext(frame:preprocess(contentText)):done()
return html
end
function round(num, numDecimalPlaces)
local mult = 10^(numDecimalPlaces or 0)
return math.floor(num * mult + 0.5) / mult
end
function split(inputstr, sep)
if sep == nil then
sep = "%s"
end
local t={}
for str in string.gmatch(inputstr, "([^"..sep.."]+)") do
table.insert(t, str)
end
return t
end
return p