Module:ResourceInfoboxGenerator

From Corsair Cove Official Wiki
Revision as of 17:43, 2 August 2026 by Dorce (talk | contribs) (Created page with "local p = {} -- Load your data table once local rData = mw.loadData("Module:ResourceData") local bData = mw.loadData("Module:BuildingData") function p.makeInfobox(frame) local name = frame.args.name or mw.title.getCurrentTitle().text -- Find the ruilding in the data table local r = rData[name] if not r then return "No data found for '" .. tostring(name) .. "'" end -- Pass the data to your existing template return frame:expandTempl...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

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

local p = {}

-- Load your data table once
local rData = mw.loadData("Module:ResourceData")
local bData = mw.loadData("Module:BuildingData")

function p.makeInfobox(frame)
    local name = frame.args.name or mw.title.getCurrentTitle().text

    -- Find the ruilding in the data table
    local r = rData[name]

    if not r then
        return "No data found for '" .. tostring(name) .. "'"
    end

    -- Pass the data to your existing template
    return frame:expandTemplate{
        title = "Resource infobox",
        args = {
            title = r.name,
            ricon_filename = r.iconFile,
            category = r.category,
            description = r.description,
            stats_list = "* [[Warehouse]] Stack Size: " .. r.stack_size .. "\n* [[Trade Post]] Stack Value: " .. r.stack_value
        }
    }
end

return p