Module:Bribes: Difference between revisions

From IdleOn MMO Wiki
mNo edit summary
mNo edit summary
Line 17: Line 17:
function p.bribez()
function p.bribez()
     local ret = ""
     local ret = ""
     for _, bribeData in pairs(data) do
    local tabledata = {}
         local name = bribeData["name"]
   
         local desc = bribeData["desc"]
     for _, bribe in pairs(data) do
         local cost = bribeData["cost"]
        tabledata[#tabledata+1] = bribe
         local intName = bribeData["intName"]
    end
 
    for _, bribe in pairs(tabledata) do
         local name = bribe.name
         local desc = bribe.desc
         local cost = bribe.cost
         local intName = bribe.intName
         if intName == "BribeExpansion" then
         if intName == "BribeExpansion" then
             ret = ret .. string.format(
             ret = ret .. string.format(

Revision as of 17:20, 8 March 2024

hewwo


local data = mw.loadJsonData('Module:Bribes/data.json')
local p = {}
local Loops = require("Module:Loops")

local ROW_TEMPLATE = [=[<tr>
<td>%s</td>
<td>%s</td>
<td>%s</td>
</tr>]=]

local ROW_TEMPLATE_EXPANSION = [=[<tr>
<th>%s</th>
<th>%s</th>
<th>%s</th>
</tr>]=]

function p.bribez()
    local ret = ""
    local tabledata = {}
    
    for _, bribe in pairs(data) do
        tabledata[#tabledata+1] = bribe
    end

    for _, bribe in pairs(tabledata) do
        local name = bribe.name
        local desc = bribe.desc
        local cost = bribe.cost
        local intName = bribe.intName
        if intName == "BribeExpansion" then
            ret = ret .. string.format(
                ROW_TEMPLATE_EXPANSION,
                name,
                desc,
                cost
            )
        else
            ret = ret .. string.format(
                ROW_TEMPLATE,
                name,
                desc,
                cost
            )
        end
    end
    return ret
end
return p