Anonymous

Module:Sandbox/Skills/Cartography: Difference between revisions

From Melvor Idle
Fixed icon, sorted Table
(Added getDiscoveryRewardsTable for showing item sources from POIs)
 
(Fixed icon, sorted Table)
Line 214: Line 214:
end
end
end
end
 
table.sort(POIs, function(a, b)
local aX, aY = p.convertAxialToXY(a.coords)
local bX, bY = p.convertAxialToXY(b.coords)
if aX ~= bX then
return aX < bX
else
return aY < bY
end
end)
 
-- Build the table
-- Build the table
local resultTable = {}
local resultTable = {}
table.insert(resultTable, '==Point of Interest Discover Rewards==\r\n')
table.insert(resultTable, '==POI Discovery Rewards==\r\n')
table.insert(resultTable, '{| class="wikitable" style="text-align:left"')
table.insert(resultTable, '{| class="wikitable" style="text-align:left"')
table.insert(resultTable, '|-\r\n!|Point of Interest!!X!!Y!!Requirements!!Discovery Rewards\r\n')
table.insert(resultTable, '|-\r\n!|Point of Interest!!X!!Y!!Requirements!!Discovery Rewards')
for _, POI in ipairs(POIs) do
for _, POI in ipairs(POIs) do
table.insert(resultTable, '|-\r\n')
table.insert(resultTable, '\r\n|-\r\n')
local X, Y = p.convertAxialToXY(POI.coords)
local X, Y = p.convertAxialToXY(POI.coords)
--Add Icon, Name, X and Y
--Add Icon, Name, X and Y
table.insert(resultTable, '||'..'{{POIIcon|'..POI.name..'}}')
table.insert(resultTable, '||'..Icons.Icon({POI.name, type='poi'}))
table.insert(resultTable, '||'..X..'||'..Y..'||')
table.insert(resultTable, '||'..X..'||'..Y..'||')
Line 248: Line 258:
return p._getDiscoveryRewardsTable(item)
return p._getDiscoveryRewardsTable(item)
end
function p.testDiscoveryRewards()
local testTable = {}
for i, POI in pairs(SkillData.Cartography.worldMaps[1].pointsOfInterest) do
if POI.discoveryRewards ~= nil and POI.discoveryRewards.items ~= nil then
for i, reward in pairs(POI.discoveryRewards.items) do
local item = Items.getItemByID(reward.id)
local resultTable = string.gsub(p.getDiscoveryRewardsTable(item.name), "==POI Discovery Rewards==", "")
table.insert(testTable, resultTable)
end
end
end
return table.concat(testTable)
end
end