Module:EffectType: Difference between revisions
Jump to navigation
Jump to search
mNo edit summary |
(add psionic effects (coming soon)) |
||
(2 intermediate revisions by one other user not shown) | |||
Line 1: | Line 1: | ||
local p = {} | local p = {} | ||
effectTypes = {"General", "Mental", "Metabolic", "Respiratory", "Circulatory", "Contact", "Field", "Activity", "Dimensional", "Chemical", "Structural", " | effectTypes = {{"General", "Effects"}, | ||
{"Mental", "Mental Effects"}, | |||
{"Metabolic", "Metabolic Effects"}, | |||
{"Respiratory", "Respiratory Effects"}, | |||
{"Circulatory", "Circulatory Effects"}, | |||
{"Contact-based", "Contact-based Effects"}, | |||
{"Field", "Field Effects"}, | |||
{"Activity-based", "Activity-based Effects"}, | |||
{"Dimensional", "Dimensional Effects"}, | |||
{"Chemical-based", "Chemical-based Effects"}, | |||
{"Structural", "Structural Effects"}, | |||
{"Sound-based", "Sound-based Effects"}, | |||
{"Temporal", "Temporal Effects"}, | |||
{"Neurological", "Neurological Effects"}, | |||
{"Illness", "Illnesses"}, | |||
{"Psionic","Psionic Effects"} | |||
} | } | ||
classTypes = {"Minor", "Negative", "Removable", "Voluntary"} | classTypes = {{"Minor", "Minor Effects"}, | ||
{"Negative", "Negative Effects"}, | |||
{"Removable", "Removable Effects"}, | |||
{"Voluntary", "Voluntary Effects"} | |||
} | |||
function p.getTypes(frame) | function p.getTypes(frame) | ||
Line 22: | Line 41: | ||
if bit == "1" then | if bit == "1" then | ||
if i < 25 then | if i < 25 then | ||
table.insert(typeList, effectTypes[i]) | table.insert(typeList, | ||
string.format("%s[[Category:%s]]", | |||
effectTypes[i][1], | |||
effectTypes[i][2])) | |||
elseif i < 29 then | elseif i < 29 then | ||
table.insert(typeList, classTypes[i-24]) | table.insert(typeList, | ||
string.format("%s[[Category:%s]]", | |||
classTypes[i-24][1], | |||
classTypes[i-24][2])) | |||
else | else | ||
error("This type string is way too long (> 28 chars)!)") | error("This type string is way too long (> 28 chars)!)") |
Latest revision as of 20:13, 11 April 2021
local p = {}
effectTypes = {{"General", "Effects"},
{"Mental", "Mental Effects"},
{"Metabolic", "Metabolic Effects"},
{"Respiratory", "Respiratory Effects"},
{"Circulatory", "Circulatory Effects"},
{"Contact-based", "Contact-based Effects"},
{"Field", "Field Effects"},
{"Activity-based", "Activity-based Effects"},
{"Dimensional", "Dimensional Effects"},
{"Chemical-based", "Chemical-based Effects"},
{"Structural", "Structural Effects"},
{"Sound-based", "Sound-based Effects"},
{"Temporal", "Temporal Effects"},
{"Neurological", "Neurological Effects"},
{"Illness", "Illnesses"},
{"Psionic","Psionic Effects"}
}
classTypes = {{"Minor", "Minor Effects"},
{"Negative", "Negative Effects"},
{"Removable", "Removable Effects"},
{"Voluntary", "Voluntary Effects"}
}
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,
string.format("%s[[Category:%s]]",
effectTypes[i][1],
effectTypes[i][2]))
elseif i < 29 then
table.insert(typeList,
string.format("%s[[Category:%s]]",
classTypes[i-24][1],
classTypes[i-24][2]))
else
error("This type string is way too long (> 28 chars)!)")
end
end
i = i + 1
end
return typeList
end
return p