58 - Can't create routes from Gatherer nodes (5.0.4)
What steps will reproduce the problem?
The new version of Gathere doesn't use the same parameters for its Storage APIs. When trying to add a route using Gatherer source, Routes will compain about no data available from Gatherer.
What version of the product are you using?
v1.4.2-1-gedd66e7
Do you have an error log of what happened?
No error
Please provide any additional information below.
Here are the two functions I had to modify to make it work. In short, we need to pass the area id instead of the continent and zone name.
local function Summarize(data, zone) local amount_of = {} local db_type_of = {} --local continent = Routes.LZName[zone][3] local zone_id = Routes.LZName[zone][2] -- This loop works only because of a bug in Gatherer. -- Gatherer may be fixed in the future and break this loop. for _, node, db_type in _G.Gatherer.Storage.ZoneGatherNames(zone_id) do amount_of[node] = (amount_of[node] or 0) + 1 db_type_of[node] = db_type end for node, count in pairs(amount_of) do local db_type = db_type_of[node] local translatednode = _G.Gatherer.Util.GetNodeName(node) data[ ("%s;%s;%s;%s"):format(SourceName, db_type, node, count) ] = ("%s - %s (%d)"):format(L[SourceName..db_type], translatednode, count) end return data end local function AppendNodes(node_list, zone, db_type, node_type) --local continent = Routes.LZName[zone][3] local zone_id = Routes.LZName[zone][2] node_type = tonumber(node_type) -- posX, posY, timesGathered, indoors, harvested, inspected, source = GetGatherInfo(C, Z, node_type, db_type, index) for index, posX, posY, inspected, indoors in _G.Gatherer.Storage.ZoneGatherNodes(zone_id, db_type) do if _G.Gatherer.Storage.GetGatherInfo(zone_id, node_type, db_type, index) then tinsert( node_list, floor(posX * 10000 + 0.5) * 10000 + floor(posY * 10000 + 0.5) ) end end -- return the node_type for auto-adding local translatednode = _G.Gatherer.Util.GetNodeName(node_type) return translatednode, translatednode, translate_db_type[db_type] end
And here is some code for the routes to update when there is a new node added to Gatherer.
local idToName = nil local mapNameToRealName = nil local function getZoneNameFromIds(cId, zId) if not idToName then -- build the table to get the zone name from the continentId and the ZoneId idToName = {} mapNameToRealName = {} for zoneName, zoneTable in pairs(Routes.LZName) do local continentId, zoneId = zoneTable[3], zoneTable[4] idToName[continentId] = idToName[continentId] or {} idToName[continentId][zoneId] = zoneName mapNameToRealName[zoneTable[1]] = zoneName end end return idToName[cId] and idToName[cId][zId] or "" end if _G.Gatherer and _G.Gatherer.Storage.AddNode then local origAddNode = _G.Gatherer.Storage.AddNode _G.Gatherer.Storage.AddNode = function(nodeID, gatherType, zoneToken, gatherX, gatherY, source, incrementCount, indoorFloor) local index, previousInspected, previousHarvested = origAddNode(nodeID, gatherType, zoneToken, gatherX, gatherY, source, incrementCount, indoorFloor) -- Is it a new node? if previousHarvested == 0 or previousInspected == 0 then local zoneName = _G.Gatherer.ZoneTokens.ZoneNames[zoneToken] local nodeName = _G.Gatherer.Util.GetNodeName(nodeID) local newCoord = Routes:getID(gatherX, gatherY) Routes:InsertNode(zoneName, newCoord, nodeName) end return index, previousInspected, previousHarvested end end local lastTime local function RefreshZoneNodes(mapName) if not mapNameToRealName then getZoneNameFromIds(1, 1) end -- Build mapNameToRealName is needed local zoneName = mapNameToRealName[mapName] or "error" if zoneName == "error" then return end -- Thruttle if lastTime and lastTime < time() + 30 then return end lastTime = time() local continentId = zoneName and Routes.LZName[zoneName][3] or _G.SetMapToCurrentZone() or _G.GetCurrentMapZone() local zoneId = zoneName and Routes.LZName[zoneName][4] or _G.GetCurrentMapContinent() zoneName = zoneName or getZoneNameFromIds(continentId, zoneId) for index, objectId, gType in _G.Gatherer.Storage.ZoneGatherNames( zoneId ) do local x, y = _G.Gatherer.Storage.GetGatherInfo( 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
Thanks for a great addon!
| Name | Description | Size | MD5 |
|---|---|---|---|
| Gatherer.lua | Gatherer.lua plugin file ... | 6.0 KiB | dfe0de9c72bc... |
| User | When | Change |
|---|---|---|
| LaoTseu | Jun 09, 2013 at 12:05 UTC | Deleted attachment Gatherer.lua: Replaced it with a cleaner version. I ran findglobal on it. |
| LaoTseu | Jun 09, 2013 at 12:04 UTC | Added attachment Gatherer.lua |
| LaoTseu | Jun 09, 2013 at 11:49 UTC | Changed description:And here is some code for the routes to update when there is a new node added to Gatherer. <<code lua>> + local idToName = nil + local mapNameToRealName = nil + local function getZoneNameFromIds(cId, zId) + if not idToName then + -- build the table to get the zone name from the continentId and the ZoneId + idToName = {} + mapNameToRealName = {} + for zoneName, zoneTable in pairs(Routes.LZName) do + local continentId, zoneId = zoneTable[3], zoneTable[4] + idToName[continentId] = idToName[continentId] or {} + idToName[continentId][zoneId] = zoneName + + mapNameToRealName[zoneTable[1]] = zoneName + end + end + + return idToName[cId] and idToName[cId][zId] or "" + end + + if _G.Gatherer and _G.Gatherer.Storage.AddNode then local origAddNode = _G.Gatherer.Storage.AddNode _G.Gatherer.Storage.AddNode = function(nodeID, gatherType, zoneToken, gatherX, gatherY, source, incrementCount, indoorFloor) ---------------------------------------- return index, previousInspected, previousHarvested end end + + local lastTime + local function RefreshZoneNodes(mapName) + if not mapNameToRealName then getZoneNameFromIds(1, 1) end -- Build mapNameToRealName is needed + local zoneName = mapNameToRealName[mapName] or "error" + if zoneName == "error" then return end + + -- Thruttle + if lastTime and lastTime < time() + 30 then return end + lastTime = time() + + local continentId = zoneName and Routes.LZName[zoneName][3] or _G.SetMapToCurrentZone() or _G.GetCurrentMapZone() + local zoneId = zoneName and Routes.LZName[zoneName][4] or _G.GetCurrentMapContinent() + zoneName = zoneName or getZoneNameFromIds(continentId, zoneId) + + for index, objectId, gType in _G.Gatherer.Storage.ZoneGatherNames( zoneId ) do + local x, y = _G.Gatherer.Storage.GetGatherInfo( 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 + <</code>> Thanks for a great addon! |
| LaoTseu | Jun 09, 2013 at 11:43 UTC | Added attachment Gatherer.lua |
| LaoTseu | Jun 09, 2013 at 11:30 UTC | Changed description: if _G.Gatherer and _G.Gatherer.Storage.AddNode then
local origAddNode = _G.Gatherer.Storage.AddNode
_G.Gatherer.Storage.AddNode = function(nodeID, gatherType, zoneToken, gatherX, gatherY, source, incrementCount, indoorFloor)
- local index, previousInspected, previousHarvested = origAddNode(nodeID, gatherType, zoneToken, gatherX, gatherY, source, incrementCount, indoorFloor)
+ local index, previousInspected, previousHarvested = origAddNode(nodeID, gatherType, zoneToken, gatherX, gatherY, source, incrementCount, indoorFloor)
- -- Is it a new node?
+ -- Is it a new node?
- if previousHarvested == 0 or previousInspected == 0 then
+ if previousHarvested == 0 or previousInspected == 0 then
- local zoneName = _G.Gatherer.ZoneTokens.ZoneNames[zoneToken]
+ local zoneName = _G.Gatherer.ZoneTokens.ZoneNames[zoneToken]
- local nodeName = _G.Gatherer.Util.GetNodeName(nodeID)
+ local nodeName = _G.Gatherer.Util.GetNodeName(nodeID)
- local newCoord = Routes:getID(gatherX, gatherY)
+ local newCoord = Routes:getID(gatherX, gatherY)
- Routes:InsertNode(zoneName, newCoord, nodeName)
+ Routes:InsertNode(zoneName, newCoord, nodeName)
- end
+ end
- return index, previousInspected, previousHarvested
+ return index, previousInspected, previousHarvested
end
end
<</code>> |
| LaoTseu | Jun 09, 2013 at 11:26 UTC | Changed description:<</code>> + And here is some code for the routes to update when there is a new node added to Gatherer. + + <<code lua>> + if _G.Gatherer and _G.Gatherer.Storage.AddNode then + local origAddNode = _G.Gatherer.Storage.AddNode + _G.Gatherer.Storage.AddNode = function(nodeID, gatherType, zoneToken, gatherX, gatherY, source, incrementCount, indoorFloor) + local index, previousInspected, previousHarvested = origAddNode(nodeID, gatherType, zoneToken, gatherX, gatherY, source, incrementCount, indoorFloor) + + -- Is it a new node? + if previousHarvested == 0 or previousInspected == 0 then + local zoneName = _G.Gatherer.ZoneTokens.ZoneNames[zoneToken] + local nodeName = _G.Gatherer.Util.GetNodeName(nodeID) + local newCoord = Routes:getID(gatherX, gatherY) + Routes:InsertNode(zoneName, newCoord, nodeName) + end + + return index, previousInspected, previousHarvested + end + end + <</code>> + Thanks for a great addon! |
| LaoTseu | Sep 03, 2012 at 04:01 UTC | Create |
- Reply
- #12
Dedsauce Jul 12, 2013 at 02:41 UTC - 0 likesThis solution worked PERFECTLY! Thanks a lot!
- Reply
- #11
LaoTseu Jun 09, 2013 at 11:42 UTC - 0 likesJust saw the message from KeesB so I'm attaching the modified file. In case I've missed anything when pasting the code.
My tab is set to 3 spaces in case the formatting doesn't make sense to you.
- Reply
- #10
LaoTseu Jun 09, 2013 at 11:27 UTC - 0 likes2013-06-09
Added code for Routes to be dynamically updated when a new node is added to Gatherer.
- Reply
- #9
KeesB Apr 30, 2013 at 12:34 UTC - 0 likesThis problem is still existing for me in version v1.4.2-7-gf8ba474. It has been persistent in all versions since v1.4.2-1-gedd66e7.
I've not been able to modify the workaround from LaoTseu for the newer versions so I've been using an older modified Gatherer.lua instead.
Routes showes the number of nodes available but when creating a route Routes can not find the nodes.
- Reply
- #8
iamkelly666 Dec 30, 2012 at 02:54 UTC - 0 likesI found a fix for the mini map lines moving. I dont know alot about programing so i could mess something else up. From what i could figure all of the zones were changed to be considered "indoors" or atleast to routes its all indoors. Thats why checking Minimap when indoors works. But that makes it use the indoors minimap size for drawling lines which makes it not work.
So I edited Routes.lua and replaced (code you want to look for and replace)
With (code you want instead of the code above)
I just copied the outdoor minimapsize and put it in the indoor minimapsize. Like i said this could really mess something else up that i dont know about but it works for me... for now.
- Reply
- #7
darko8472 Nov 23, 2012 at 07:57 UTC - 1 likeLaoTseu, thank you SO MUCH for posting this. I've edited the LUA to include your changes above on my copy of Routes and it works again! Many many thanks.
- Reply
- #6
ULTIMATESEVEN Oct 23, 2012 at 21:02 UTC - 0 likesSame here
- Reply
- #5
rfrehv Oct 17, 2012 at 09:29 UTC - 0 likes@Radoznali: Go
Well, if it updates it's gonna be broken again. Also check your map, not your minimap. There's a problem with MoP I think where it only shows on minimap if you check to draw "minimap when indoors". (It was working fine on my druid on cata maps, will check later)
BFAK:rfrehv,90745380,2dbb873d82b12291e38904bee9d83ed3701e0942cdeaa315110c397638118ac9
- Reply
- #4
Radoznali Oct 06, 2012 at 18:17 UTC - 0 likesI tried this and it didnt work for me.it takes all nodes but never put line on map.Maybe it was dif versions of addon since i used latest alpha,but never the less its still broken for me.
- Reply
- #3
rfrehv Sep 24, 2012 at 23:04 UTC - 0 likesThis also fixed it for me :)