Module:FertilizerWindows: Difference between revisions
From Piñata Journal
More actions
Admin Jeremy (talk | contribs) No edit summary |
Admin Jeremy (talk | contribs) No edit summary |
||
| Line 3: | Line 3: | ||
local icon = '[[File:Fertilizer bag icon.png|45px]]' | local icon = '[[File:Fertilizer bag icon.png|45px]]' | ||
function | local function makeWindow(window,count) | ||
local label | |||
local label | |||
if window == 0 then | if window == 0 then | ||
label = 'After Planting' | label = 'After Planting' | ||
elseif window == 1 then | |||
label = 'After 1st Bud Burst' | |||
elseif window == 2 then | |||
label = 'After 2nd Bud Burst' | |||
elseif window == 3 then | |||
label = 'After 3rd Bud Burst' | |||
else | else | ||
label = 'After ' .. window .. ' Bud Burst' | label = 'After '..window..'th Bud Burst' | ||
end | end | ||
| Line 22: | Line 24: | ||
return '<div class="vp-fert-window">' | return '<div class="vp-fert-window">' | ||
.. '<div class="vp-fert- | ..'<div class="vp-fert-header">'..label..'</div>' | ||
.. '<div class="vp-fert-icons">' .. icons .. '</div>' | ..'<div class="vp-fert-icons">'..icons..'</div>' | ||
.. '</div>' | ..'</div>' | ||
end | |||
function p.render(frame) | |||
local w = {} | |||
for i=0,4 do | |||
w[i] = tonumber(frame.args[i+1]) or 0 | |||
end | |||
-- find LAST fertilization window | |||
local last = 0 | |||
for i=4,0,-1 do | |||
if w[i] > 0 then | |||
last = i | |||
break | |||
end | |||
end | |||
local out = '' | |||
for i=0,last do | |||
out = out .. makeWindow(i,w[i]) | |||
end | |||
return out | |||
end | end | ||
return p | return p | ||
Revision as of 11:17, 25 February 2026
Documentation for this module may be created at Module:FertilizerWindows/doc
local p = {}
local icon = '[[File:Fertilizer bag icon.png|45px]]'
local function makeWindow(window,count)
local label
if window == 0 then
label = 'After Planting'
elseif window == 1 then
label = 'After 1st Bud Burst'
elseif window == 2 then
label = 'After 2nd Bud Burst'
elseif window == 3 then
label = 'After 3rd Bud Burst'
else
label = 'After '..window..'th Bud Burst'
end
local icons = ''
for i=1,count do
icons = icons .. icon
end
return '<div class="vp-fert-window">'
..'<div class="vp-fert-header">'..label..'</div>'
..'<div class="vp-fert-icons">'..icons..'</div>'
..'</div>'
end
function p.render(frame)
local w = {}
for i=0,4 do
w[i] = tonumber(frame.args[i+1]) or 0
end
-- find LAST fertilization window
local last = 0
for i=4,0,-1 do
if w[i] > 0 then
last = i
break
end
end
local out = ''
for i=0,last do
out = out .. makeWindow(i,w[i])
end
return out
end
return p