Module:Bribes: Difference between revisions

From IdleOn MMO Wiki
(Created page with "local data = mw.loadJsonData('Module:Gemshop/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 = "" for _, bribeData in pairs(data) do local name = bribeData["name"] local desc = bribeData["desc"] local cost = Loops.coinDisplay({args = {co...")
 
mNo edit summary
Line 20: Line 20:
         local name = bribeData["name"]
         local name = bribeData["name"]
         local desc = bribeData["desc"]
         local desc = bribeData["desc"]
         local cost = Loops.coinDisplay({args = {coins = bribeData["cost"]}})
         local cost = Loops.coinDisplay({args = {coins = tostring(bribeData["cost"])}})
         local intName = bribeData["intName"]
         local intName = bribeData["intName"]
         if intName == "BribeExpansion" then
         if intName == "BribeExpansion" then

Revision as of 16:13, 8 March 2024

hewwo


local data = mw.loadJsonData('Module:Gemshop/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 = ""
    for _, bribeData in pairs(data) do
        local name = bribeData["name"]
        local desc = bribeData["desc"]
        local cost = Loops.coinDisplay({args = {coins = tostring(bribeData["cost"])}})
        local intName = bribeData["intName"]
        if intName == "BribeExpansion" then
            name = "<th>" .. name .. "</th>"
            desc = "<th>" .. desc .. "</th>"
            cost = "<th>" .. cost .. "</th>"
        else
            name = "<td>" .. name .. "</td>"
            desc = "<td>" .. desc .. "</td>"
            cost = "<td>" .. cost .. "</td>"
        end
        ret = ret .. string.format(
            intName == "BribeExpansion" and ROW_TEMPLATE or ROW_TEMPLATE_EXPANSION,
            name,
            desc,
            cost
        )
    end
    return ret
end
return p