Anonymous

Module:Skills/Gathering: Difference between revisions

From Melvor Idle
getMiningOresTable: Fix & include shop purchases in requirements column
(Fix tool tables, and refactor while we're at it)
(getMiningOresTable: Fix & include shop purchases in requirements column)
Line 206: Line 206:
local result = '{|class="wikitable sortable stickyHeader"'
local result = '{|class="wikitable sortable stickyHeader"'
result = result..'\r\n|- class="headerRow-0"'
result = result..'\r\n|- class="headerRow-0"'
result = result..'\r\n!colspan=2|Ore!!'..Icons.Icon({'Mining', type='skill', notext=true})..' Level'
result = result..'\r\n!colspan=2|Ore!!Requirements'
result = result..'!!XP!!Respawn Time!!Ore Value'
result = result..'!!XP!!Respawn Time!!Ore Value'


Line 212: Line 212:
table.sort(mineData, function(a, b) return a.level < b.level end)
table.sort(mineData, function(a, b) return a.level < b.level end)


for i, oreData in Shared.skpairs(mineData) do
for i, oreData in ipairs(mineData) do
local ore = Items.getItemByID(oreData.productID)
local ore = Items.getItemByID(oreData.productId)
local reqText = { Icons._SkillReq('Mining', oreData.level) }
if oreData.shopItemPurchased ~= nil then
local purchase = Shop.getPurchaseByID(oreData.shopItemPurchased)
if purchase ~= nil then
table.insert(reqText, Shop._getPurchaseIcon({purchase}) .. ' purchased')
end
end
local respawnSort, respawnText = 0, 'N/A'
if oreData.hasPassiveRegen then
respawnSort = oreData.baseRespawnInterval / 1000
respawnText = Shared.timeString(respawnSort, true)
end
result = result..'\r\n|-\r\n|style="min-width:25px"|'..Icons.Icon({ore.name, type='item', size='50', notext=true})
result = result..'\r\n|-\r\n|style="min-width:25px"|'..Icons.Icon({ore.name, type='item', size='50', notext=true})
result = result..'||'..Icons.Icon({ore.name, type='item', noicon=true})
result = result..'||'..Icons.Icon({ore.name, type='item', noicon=true})
result = result..'||style="text-align:right"|'..oreData.level..'||style="text-align:right"|'..oreData.baseExperience
result = result..'||data-sort-value="' .. oreData.level ..'"| '..table.concat(reqText, '<br/>')..'||style="text-align:right"|'..oreData.baseExperience
result = result..'||style="text-align:right" data-sort-value="'..oreData.baseRespawnInterval..'"|'
result = result..'||style="text-align:right" data-sort-value="'..respawnSort..'"|'
result = result..Shared.timeString(oreData.baseRespawnInterval / 1000, true)
result = result..respawnText
result = result..'||data-sort-value="'..ore.sellsFor..'"|'..Icons.GP(ore.sellsFor)
result = result..'||data-sort-value="'..ore.sellsFor..'"|'..Icons.GP(ore.sellsFor)
end
end