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: Difference between revisions

From Piñata Journal
No edit summary
No edit summary
Line 1: Line 1:
local p = {}
local p = {}


local icon = '[[File:Fertilizer bag icon.png|45px]]'
local fertIcon = '[[File:Fertilizer bag icon.png|45px]]'
local noIcon  = '[[File:Red_x_icon.png|45px]]'


local function makeWindow(window,count)
local function makeWindow(window,count)
Line 19: Line 20:


     local icons = ''
     local icons = ''
     for i=1,count do
 
        icons = icons .. icon
     if count == 0 then
        icons = noIcon
    else
        for i=1,count do
            icons = icons .. fertIcon
        end
     end
     end


Line 36: Line 42:
     end
     end


    -- find LAST fertilization window
     local last = 0
     local last = 0
     for i=4,0,-1 do
     for i=4,0,-1 do

Revision as of 11:37, 25 February 2026

Documentation for this module may be created at Module:FertilizerWindows/doc

local p = {}

local fertIcon = '[[File:Fertilizer bag icon.png|45px]]'
local noIcon   = '[[File:Red_x_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 = ''

    if count == 0 then
        icons = noIcon
    else
        for i=1,count do
            icons = icons .. fertIcon
        end
    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

    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