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

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

local p = {}

local fertIcon = '[[File:Fertilizer bag icon.png|45px|class=vp-fert-bag]]'
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 buds grow'
    elseif window == 2 then
        label = 'After 2nd buds grow'
    elseif window == 3 then
        label = 'After 3rd buds grow'
    else
        label = 'After '..window..'th buds grow'
    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