Module:EffectType: Difference between revisions
Jump to navigation
Jump to search
(Created page with "local p = {} effectTypes = {"General", "Mental", "Metabolic", "Respiratory", "Circulatory", "Contact", "Field", "Activity", "Dimensional", "Chemical", "Structural", "Sonic",...") |
mNo edit summary |
||
Line 8: | Line 8: | ||
function p.getTypes(frame) | function p.getTypes(frame) | ||
frame = mw.getCurrentFrame() | frame = mw.getCurrentFrame() | ||
typeList = p.parse(frame.args[1]) | if frame.args[1] == nil or frame.args[1] == "" then | ||
error("An argument must be provided!") | |||
end | |||
typeList = p.parse(mw.text.trim(frame:preprocess(frame.args[1]))) | |||
return table.concat(typeList, ', ') | return table.concat(typeList, ', ') | ||
end | end |
Revision as of 02:03, 12 March 2021
local p = {}
effectTypes = {"General", "Mental", "Metabolic", "Respiratory", "Circulatory", "Contact", "Field", "Activity", "Dimensional", "Chemical", "Structural", "Sonic", "Temporal", "Neurological", "Disease"
}
classTypes = {"Minor", "Negative", "Removable", "Voluntary"}
function p.getTypes(frame)
frame = mw.getCurrentFrame()
if frame.args[1] == nil or frame.args[1] == "" then
error("An argument must be provided!")
end
typeList = p.parse(mw.text.trim(frame:preprocess(frame.args[1])))
return table.concat(typeList, ', ')
end
function p.parse(bits)
typeList = {}
rbits = string.reverse(bits)
i = 1
for bit in string.gmatch(rbits, "[01]") do
if bit == "1" then
if i < 25 then
table.insert(typeList, effectTypes[i])
elseif i < 29 then
table.insert(typeList, classTypes[i-24])
else
error("This type string is way too long (> 28 chars)!)")
end
end
i = i + 1
end
return typeList
end
return p