Module:Sandbox/Skills/Cartography: Difference between revisions

no edit summary
(Adding get POI by XY coords function)
No edit summary
Line 222: Line 222:
end
end


function p._getDiscoveryRewardsTable(item)
function p._getDiscoveryRewardsTable(items)
local POIs = {}
local POIs = {}
for i, POI in pairs(SkillData.Cartography.worldMaps[1].pointsOfInterest) do
for i, POI in pairs(SkillData.Cartography.worldMaps[1].pointsOfInterest) do
if POI.discoveryRewards ~= nil and POI.discoveryRewards.items ~= nil then
if POI.discoveryRewards ~= nil and POI.discoveryRewards.items ~= nil then
for i, reward in pairs(POI.discoveryRewards.items) do
for i, reward in pairs(POI.discoveryRewards.items) do
if reward.id == item.id then
for j, item in ipairs(items) do
table.insert(POIs, POI)
if reward.id == item.id then
table.insert(POIs, POI)
break
end
end
end
end
end
Line 260: Line 263:


function p.getDiscoveryRewardsTable(frame)
function p.getDiscoveryRewardsTable(frame)
local itemName = frame.args ~= nil and frame.args[1] or frame
local itemNames = frame.args ~= nil and frame.args or frame
local item = Items.getItem(itemName)
local items = {}
if item == nil then
for i, itemName in ipairs(itemNames) do
return Shared.printError('No item named "' .. itemName .. '" exists in the data module')
item = Items.getItem(itemName)
if item ~= nil then
items[i] = item
end
end
if #items == nil then
return Shared.printError('No items found for with names: "' .. itemNames .. '"')
end
end
return '==POI Discovery Rewards==\n' .. p._getDiscoveryRewardsTable(item)
return '==POI Discovery Rewards==\n' .. p._getDiscoveryRewardsTable(items)
end
end


Line 274: Line 283:
if POI.discoveryRewards ~= nil and POI.discoveryRewards.items ~= nil then
if POI.discoveryRewards ~= nil and POI.discoveryRewards.items ~= nil then
local item = Items.getItemByID(POI.discoveryRewards.items[1].id)
local item = Items.getItemByID(POI.discoveryRewards.items[1].id)
table.insert(testTable, p._getDiscoveryRewardsTable(item))
table.insert(testTable, p._getDiscoveryRewardsTable({item}))
end
end
end
end
432

edits