Module:ESColor: Difference between revisions
From Teriock
More actions
// via Wikitext Extension for VSCode |
// via Wikitext Extension for VSCode |
||
| (8 intermediate revisions by the same user not shown) | |||
| Line 1: | Line 1: | ||
local p | local p = {} | ||
function p.c ( frame ) | function p.c ( frame ) | ||
local life = (frame.args['life | local life = tonumber(frame.args['life']) | ||
local storm = (frame.args['storm | local storm = tonumber(frame.args['storm']) | ||
local necro = (frame.args['necro | local necro = tonumber(frame.args['necro']) | ||
local flame = (frame.args['flame | local flame = tonumber(frame.args['flame']) | ||
local nature = (frame.args['nature | local nature = tonumber(frame.args['nature']) | ||
life_color = ' | life_color = 'es-life' | ||
storm_color = ' | storm_color = 'es-storm' | ||
necro_color = ' | necro_color = 'es-necro' | ||
flame_color = ' | flame_color = 'es-flame' | ||
nature_color = ' | nature_color = 'es-nature' | ||
multi_color = ' | multi_color = 'es-multi' | ||
local color_counter = life + storm + necro + flame + nature | local color_counter = life + storm + necro + flame + nature | ||
if color_counter ~= 1 then | if color_counter ~= 1 then | ||
| Line 29: | Line 29: | ||
end | end | ||
return multi_color | return multi_color | ||
end | |||
function p.t ( frame ) | |||
local life = tonumber(frame.args['life']) | |||
local storm = tonumber(frame.args['storm']) | |||
local necro = tonumber(frame.args['necro']) | |||
local flame = tonumber(frame.args['flame']) | |||
local nature = tonumber(frame.args['nature']) | |||
local elementsList = {} | |||
local elementsString = '' | |||
if life == 1 then | |||
table.insert(elementsList, '{{L|Ability|Life Elder Sorcery|Life}}') | |||
end | |||
if storm == 1 then | |||
table.insert(elementsList, '{{L|Ability|Storm Elder Sorcery|Storm}}') | |||
end | |||
if necro == 1 then | |||
table.insert(elementsList, '{{L|Ability|Necromancy Elder Sorcery|Necromancy}}') | |||
end | |||
if flame == 1 then | |||
table.insert(elementsList, '{{L|Ability|Flame Elder Sorcery|Flame}}') | |||
end | |||
if nature == 1 then | |||
table.insert(elementsList, '{{L|Ability|Nature Elder Sorcery|Nature}}') | |||
end | |||
if #elementsList == 0 then | |||
table.insert(elementsList, '{{L|Ability|Celestial Elder Sorcery Words|Celestial}}') | |||
end | |||
if #elementsList > 1 then | |||
elementsList[#elementsList] = 'and ' .. elementsList[#elementsList] | |||
end | |||
if #elementsList > 2 then | |||
elementsString = table.concat(elementsList, ', ') | |||
else | |||
elementsString = table.concat(elementsList, ' ') | |||
end | |||
return frame:preprocess(elementsString) | |||
end | end | ||
return p | return p | ||
Latest revision as of 17:32, 23 April 2025
Documentation for this module may be created at Module:ESColor/doc
local p = {}
function p.c ( frame )
local life = tonumber(frame.args['life'])
local storm = tonumber(frame.args['storm'])
local necro = tonumber(frame.args['necro'])
local flame = tonumber(frame.args['flame'])
local nature = tonumber(frame.args['nature'])
life_color = 'es-life'
storm_color = 'es-storm'
necro_color = 'es-necro'
flame_color = 'es-flame'
nature_color = 'es-nature'
multi_color = 'es-multi'
local color_counter = life + storm + necro + flame + nature
if color_counter ~= 1 then
return multi_color
end
if life == 1 then
return life_color
elseif storm == 1 then
return storm_color
elseif necro == 1 then
return necro_color
elseif flame == 1 then
return flame_color
elseif nature == 1 then
return nature_color
end
return multi_color
end
function p.t ( frame )
local life = tonumber(frame.args['life'])
local storm = tonumber(frame.args['storm'])
local necro = tonumber(frame.args['necro'])
local flame = tonumber(frame.args['flame'])
local nature = tonumber(frame.args['nature'])
local elementsList = {}
local elementsString = ''
if life == 1 then
table.insert(elementsList, '{{L|Ability|Life Elder Sorcery|Life}}')
end
if storm == 1 then
table.insert(elementsList, '{{L|Ability|Storm Elder Sorcery|Storm}}')
end
if necro == 1 then
table.insert(elementsList, '{{L|Ability|Necromancy Elder Sorcery|Necromancy}}')
end
if flame == 1 then
table.insert(elementsList, '{{L|Ability|Flame Elder Sorcery|Flame}}')
end
if nature == 1 then
table.insert(elementsList, '{{L|Ability|Nature Elder Sorcery|Nature}}')
end
if #elementsList == 0 then
table.insert(elementsList, '{{L|Ability|Celestial Elder Sorcery Words|Celestial}}')
end
if #elementsList > 1 then
elementsList[#elementsList] = 'and ' .. elementsList[#elementsList]
end
if #elementsList > 2 then
elementsString = table.concat(elementsList, ', ')
else
elementsString = table.concat(elementsList, ' ')
end
return frame:preprocess(elementsString)
end
return p