Toggle menu
Toggle preferences menu
Toggle personal menu
Not logged in
Your IP address will be publicly visible if you make any edits.

Module:FertilizerWindows

From Piñata Journal
Revision as of 11:17, 25 February 2026 by Admin Jeremy (talk | contribs)

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