FANDOM


local p = {}
 
local data = mw.loadData("Module:Asset/data")
 
function p.listAsset(frame)
    local rawname = tostring(frame.args[1])
    local price = data[rawname]['price']
    local listAssetPrice
    listAssetPrice = frame:expandTemplate{ title = 'mb', args = { price } } or "Unknown"
    return listAssetPrice
end
 
function p.res(frame)
    local rawname = tostring(frame.args[1])
    local name = data[rawname]['name']
    local link = '[[:Category:' .. name .. '|' .. name .. ']]'
    local category = '[[Category:' .. name .. ']]'
    local link2
    local price
    local fullcost
    local img
    local amount = tonumber(frame.args[2]) or 0
    local version = frame.args['version']
    local cat = data[rawname]['type'] or "" or nil
 
    if rawname == 'tarpaulin' then
        link2 = link .. "<br/><small>(''a.k.a '''Tarpaulin''''')</small>"
    elseif rawname == 'field_columns' then
        link2 = link .. "<br/><small>(''a.k.a '''Aerodrome Floodlights''''')</small>"
    else
        link2 = link
    end
 
    if cat == 'Unique' then
        img = 'Unique Asset ' .. name .. '.png'
    elseif cat == 'Special' then
        img = name .. '.png'
    else
        img = 'Asset ' .. name .. '.png'
    end
 
    if cat == 'Diagram' then
        price = frame:expandTemplate{ title = 'coin', args = { data[rawname]['cost'] } }
        fullcost = tonumber(data[rawname]['cost']) * amount
        fullcost = frame:expandTemplate{ title = 'coin', args = { fullcost } }
    elseif cat == 'Special' then
        price = ""
        fullcost = ""
    elseif cat == 'SpecialAsset' then
        price = ""
        fullcost = ""
    else
        price = frame:expandTemplate{ title = 'mb', args = { data[rawname]['price'] } }
        fullcost = tonumber(data[rawname]['price']) * amount
        fullcost = frame:expandTemplate{ title = 'mb', args = { fullcost } }
    end
 
    if version == '2' then
        return p.v2(link2,img,amount,price,fullcost,category)
    else
        return p.v1(name,link,img,amount)
    end
end
 
function p.v1(name,link,img,amount)
    if amount == 0 then
        amount = ""
    elseif tonumber(amount) < 10 then
        amount = '<span style="font-family: \'Ubuntu Mono\', monospace;">0' .. tostring(amount) .. '</span>&nbsp;x&nbsp;'
    else
        amount = '<span style="font-family: \'Ubuntu Mono\', monospace;">' .. tostring(amount) .. '</span>&nbsp;x&nbsp;'
    end
    return amount .. link .. ' [[File:' .. img .. '|25px]]'
end
 
function p.v2(link2,img,amount,price,fullcost,category)
    local final
    if amount == 0 then
        final = '|-\n| colspan="4" | Invalid Asset Amount'
    else
        final = '|- style="text-align: center; vertical-align:middle"\n|' .. category .. link2 .. '||' .. '[[File:' .. img .. '|60px]] ||' .. amount .. 'x||' .. price .. '||' .. fullcost
    end
    return final
end
 
return p

Ad blocker interference detected!


Wikia is a free-to-use site that makes money from advertising. We have a modified experience for viewers using ad blockers

Wikia is not accessible if you’ve made further modifications. Remove the custom ad blocker rule(s) and the page will load as expected.