Module:Bribes: Difference between revisions

From IdleOn MMO Wiki
mNo edit summary
mNo edit summary
Line 28: Line 28:
         local intName = bribeData["intName"]
         local intName = bribeData["intName"]
         if intName == "BribeExpansion" then
         if intName == "BribeExpansion" then
             name = "<th>" .. name .. "</th>"
             ret = ret .. string.format(
            desc = "<th>" .. desc .. "</th>"
                ROW_TEMPLATE_EXPANSION,
             cost = "<th>" .. cost .. "</th>"
                name,
                desc,
                cost
             )
         else
         else
             name = "<td>" .. name .. "</td>"
             ret = ret .. string.format(
            desc = "<td>" .. desc .. "</td>"
                ROW_TEMPLATE,
             cost = "<td>" .. cost .. "</td>"
                name,
                desc,
                cost
             )
         end
         end
        ret = ret .. string.format(
            intName == "BribeExpansion" and ROW_TEMPLATE_EXPANSION or ROW_TEMPLATE,
            name,
            desc,
            cost
        )
     end
     end
     return ret
     return ret
end
end
return p
return p

Revision as of 16:57, 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 luaSux = {}
    for luaSuck in pairs(data) do
        luaSux[#luaSux + 1] = luaSuck
    end
    for _, luaSuck in pairs(luaSux) do
    	local bribeData = data[luaSuck]
        local name = bribeData["name"]
        local desc = bribeData["desc"]
        local cost = bribeData["cost"]
        local intName = bribeData["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