Difference between revisions of "Module:Thought"
Jump to navigation
Jump to search
Arcangelus (talk | contribs) m |
Arcangelus (talk | contribs) m |
||
Line 1: | Line 1: | ||
local p = {} | local p = {} | ||
local getArgs = require('Module:Arguments').getArgs | local getArgs = require('Module:Arguments').getArgs | ||
+ | valores_ingresados={"value", "value2", "value3", "value4", "value5", "value6", "value7", "value8", "value9" } | ||
-- "stack, "duration", "multi", "label", "desc", "label" | -- "stack, "duration", "multi", "label", "desc", "label" | ||
Line 11: | Line 12: | ||
if value then | if value then | ||
if value2 then | if value2 then | ||
− | return p.Thought( | + | return p.Thought(args)..'<abbr title="'..desc..'">'..label..gsub("^%l", string.upper)..'</abbr>'.." [[mood]]" |
else | else | ||
− | return '<abbr title="'..p.stacks( | + | return '<abbr title="'..p.stacks(args)..'"> '..'<abbr title="'..desc..'">'..label..gsub("^%l", string.upper)..'</abbr>'.." [[mood]]" |
end | end | ||
end | end | ||
Line 19: | Line 20: | ||
end | end | ||
− | function p.Thought( | + | function p.Thought(args)--This is just the value section. |
local valores_buscados={} | local valores_buscados={} | ||
− | |||
for i, j in ipairs(valores_ingresados) do | for i, j in ipairs(valores_ingresados) do | ||
− | local | + | local vx = valores_ingresados[i] |
− | |||
local vy = "" | local vy = "" | ||
if vx then -- Not a nil | if vx then -- Not a nil | ||
Line 37: | Line 36: | ||
end | end | ||
− | function p.stacks( | + | function p.stacks(args)--This is just the stacking section. |
− | + | if stack then | |
− | |||
− | if | ||
local va= "Stacking "..stack.."times " | local va= "Stacking "..stack.."times " | ||
− | if | + | if multi == 1 then |
− | text= "for a maximum of "..tostring( | + | text= "for a maximum of "..tostring(value*stack) |
else | else | ||
− | text= "with a "..multi.." multiplier for maximum of"..tostring( | + | text= "with a "..multi.." multiplier for maximum of"..tostring(value*( 1 - multi^stack)/(1 - multi)) |
end | end | ||
return va..text | return va..text | ||
else | else | ||
− | if | + | if multi == 1 then --What about a mult above 1? |
text = "Stacking infinitely" | text = "Stacking infinitely" | ||
else | else | ||
− | text = "Stacking with a "..multi.." multiplier for maximum of "..tostring( | + | text = "Stacking with a "..multi.." multiplier for maximum of "..tostring(value*( 1 - multi^100)/(1 - multi) ) |
end | end | ||
return text | return text | ||
end | end | ||
end | end |
Revision as of 05:31, 16 August 2024
Documentation for this module may be created at Module:Thought/doc
local p = {} local getArgs = require('Module:Arguments').getArgs valores_ingresados={"value", "value2", "value3", "value4", "value5", "value6", "value7", "value8", "value9" } -- "stack, "duration", "multi", "label", "desc", "label" function p.Main(frame) local args = getArgs(frame) return p._main(args) end function p._Main(args) if value then if value2 then return p.Thought(args)..'<abbr title="'..desc..'">'..label..gsub("^%l", string.upper)..'</abbr>'.." [[mood]]" else return '<abbr title="'..p.stacks(args)..'"> '..'<abbr title="'..desc..'">'..label..gsub("^%l", string.upper)..'</abbr>'.." [[mood]]" end end end function p.Thought(args)--This is just the value section. local valores_buscados={} for i, j in ipairs(valores_ingresados) do local vx = valores_ingresados[i] local vy = "" if vx then -- Not a nil if tonumber(vx) then --A number if tonumber(vx)<0 then vy='<b><font color="firebrick">'..vx.."</font></b>" else vy='<b><font color="forestgreen">'..vx.."</font></b>" end else vy='<b>'..vx.."</b>" --The idea is to prevent a hard to track error end valores_buscados[#valores_buscados+1]=vx end end return "<b>"..table.concat(valores_buscados,"<b>/</b>").."</b>" end function p.stacks(args)--This is just the stacking section. if stack then local va= "Stacking "..stack.."times " if multi == 1 then text= "for a maximum of "..tostring(value*stack) else text= "with a "..multi.." multiplier for maximum of"..tostring(value*( 1 - multi^stack)/(1 - multi)) end return va..text else if multi == 1 then --What about a mult above 1? text = "Stacking infinitely" else text = "Stacking with a "..multi.." multiplier for maximum of "..tostring(value*( 1 - multi^100)/(1 - multi) ) end return text end end