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
 
(8 intermediate revisions by the same user not shown)
Line 1: Line 1:
local p = {}
local p = {}


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


function p.render(frame)
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 window = tonumber(frame.args[1]) or 0
     local icons = ''
    local count = tonumber(frame.args[2]) or 0


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


     local label = ''
     return '<div class="vp-fert-window">'
        ..'<div class="vp-fert-header">'..label..'</div>'
        ..'<div class="vp-fert-icons">'..icons..'</div>'
        ..'</div>'
end


     if window == 0 then
function p.render(frame)
         label = 'after planting'
 
     else
     local w = {}
        label = 'after the ' .. window .. 'st bud burst'
    for i=0,4 do
        if window == 2 then label = 'after the 2nd bud burst' end
         w[i] = tonumber(frame.args[i+1]) or 0
         if window == 3 then label = 'after the 3rd bud burst' end
     end
         if window >= 4 then label = 'after the ' .. window .. 'th bud burst' end
 
    local last = 0
    for i=4,0,-1 do
         if w[i] > 0 then
            last = i
            break
         end
     end
     end


     local icons = ''
     local out = ''
     for i=1,count do
 
         icons = icons .. icon
     for i=0,last do
         out = out .. makeWindow(i,w[i])
     end
     end


     return '<li>' .. icons .. ' Can be fertilized <b>' .. count .. '×</b> ' .. label .. '</li>'
     return out
end
end


return p
return p

Latest revision as of 08:34, 26 February 2026

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