432
edits
(Adding get POI by XY function) |
(Allow optional comma separated list of items) |
||
(2 intermediate revisions by the same user not shown) | |||
Line 277: | Line 277: | ||
end | end | ||
function p._getDiscoveryRewardsTable( | function p._getDiscoveryRewardsTable(items) | ||
local POIs = {} | local POIs = {} | ||
for i, POI in ipairs(SkillData.Cartography.worldMaps[1].pointsOfInterest) do | for i, POI in ipairs(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 ipairs(POI.discoveryRewards.items) do | for i, reward in ipairs(POI.discoveryRewards.items) do | ||
if reward.id == item.id then | for j, item in ipairs(items) do | ||
if reward.id == item.id then | |||
table.insert(POIs, POI) | |||
break | |||
end | |||
end | end | ||
end | end | ||
Line 318: | Line 321: | ||
function p.getDiscoveryRewardsTable(frame) | function p.getDiscoveryRewardsTable(frame) | ||
local | local itemNames = frame.args ~= nil and frame.args[1] or frame | ||
local item = Items.getItem(itemName) | local items = {} | ||
if | for itemName in string.gmatch(itemNames, "[^,]*") do | ||
return Shared.printError('No | item = Items.getItem(itemName) | ||
if item ~= nil then | |||
table.insert(items, item) | |||
end | |||
end | |||
if #items == nil then | |||
return Shared.printError('No items found in game data for: "' .. itemNames .. '"') | |||
end | end | ||
local resultTable = p._getDiscoveryRewardsTable( | local resultTable = p._getDiscoveryRewardsTable(items) | ||
if resultTable == '' then | if resultTable == '' then | ||
return '' | return '' | ||
Line 336: | Line 345: | ||
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 |
edits