Also, since I didn't want to redo all my existing routes, I did the following:
local function RefreshZoneNodes(zoneName)
zoneName = zoneName or _G.SetMapToCurrentZone() or _G.GetRealZoneText()
local continentId = Routes.LZName[zoneName][3]
local zoneId = Routes.LZName[zoneName][4]
for index, objectId, gType in _G.Gatherer.Storage.ZoneGatherNames( continentId, zoneId ) do
local x, y = _G.Gatherer.Storage.GetGatherInfo(continentId, zoneId, objectId, gType, index)
if x and y then
local newCoord = Routes:getID(x, y)
local nodeName = _G.Gatherer.Util.GetNodeName(objectId)
Routes:InsertNode(zoneName, newCoord, nodeName)
end
end
end
source.RefreshZoneNodes = RefreshZoneNodes
-- /script Routes.plugins["Gatherer"].RefreshZoneNodes()
I use this to refresh the current zone or a particular zone by zone.
Here's a quick patch for Plugins\Gatherer.lua to get the nodes that are added to Gatherer after a route was first created. Just add the following code at the end:
local idToName = nil
if Gatherer and Gatherer.Api.AddGather then
local origAddGather = Gatherer.Api.AddGather
Gatherer.Api.AddGather = function(objectId, gatherType, indoorNode, gatherSource, gatherCoins, gatherLoot, wasGathered, gatherC, gatherZ, gatherX, gatherY, ...)
-- Only add route for successful addition in Gatherer
if origAddGather(objectId, gatherType, indoorNode, gatherSource, gatherCoins, gatherLoot, wasGathered, gatherC, gatherZ, gatherX, gatherY, ...) then
-- When we do the gathering ourselves
if not (gatherC and gatherZ and gatherX and gatherY) then
gatherC, gatherZ, gatherX, gatherY = Gatherer.Util.GetPositionInCurrentZone()
end
local nodeName = Gatherer.Util.GetNodeName(objectId)
local newCoord = Routes:getID(gatherX, gatherY)
if not idToName then
-- build the table to get the zone name from the continentId and the ZoneId
idToName = {}
for zoneName, zoneTable in pairs(Routes.LZName) do
local continentId, zoneId = zoneTable[3], zoneTable[4]
idToName[continentId] = idToName[continentId] or {}
idToName[continentId][zoneId] = zoneName
end
end
local zoneName = (idToName[gatherC] and idToName[gatherC][gatherZ]) or ""
Routes:InsertNode(zoneName, newCoord, nodeName)
end
end
end
There is no API to remove node in Gatherer so I didn't anything for Routes:DeleteNode()
That's correct, Gatherer does not have any method to inform other addons when it finds a new node. I've been talking to Esamynn on and off about it, he's interested in implementing something, but he's really busy.
Can you point me to the function that needs to be called in routes when an update occurs. Maybe I can hack something for new nodes on my local copy and pass it along if it's any good.
I use this to refresh the current zone or a particular zone by zone.
There is no API to remove node in Gatherer so I didn't anything for Routes:DeleteNode()
Can you point me to the function that needs to be called in routes when an update occurs. Maybe I can hack something for new nodes on my local copy and pass it along if it's any good.
Quick question: is there a way to refresh a route with new node data without deleting and recreating it?
TIA