Anonymous

Module:Calculator/AgilityObstacle: Difference between revisions

From Melvor Idle
no edit summary
No edit summary
No edit summary
Line 254: Line 254:
local function getCosts(costsTable)
local function getCosts(costsTable)
local res = {}
   
-- Order table with GP, SC first, then the other items.
-- Order table with GP, SC first, then the other items.
    local sortedCosts = {}
     if costsTable['GP'] then table.insert(res, getItemIcon('GP', costsTable['GP'])) costsTable['GP'] = nil end
     if costsTable['GP'] then table.insert(sortedCosts, {item = 'GP', amount = costsTable['GP']}) end
     if costsTable['SC'] then table.insert(res, getItemIcon('SC', costsTable['SC'])) costsTable['SC'] = nil end
     if costsTable['SC'] then table.insert(sortedCosts, {item = 'SC', amount = costsTable['SC']}) end
 
   
     local sortedCosts = Shared.sortDictionary(costsTable,  
     for k, v in pairs(costsTable) do
function(a, b) return a.item < b.amount end,
    if k ~= 'GP' and k ~= 'SC' then
function(a, b) return {item = a, amount = b} end)
    table.insert(sortedCosts, {item = k, amount = v})
 
    end
    end
   
    local res = {}
     for _, v in pairs(sortedCosts) do
     for _, v in pairs(sortedCosts) do
     table.insert(res, getItemIcon(v.item, v.amount))
     table.insert(res, getItemIcon(v.item, v.amount))
2,875

edits