[Classic] GetNumFactions() not getting past index 1
I have a function that sets the watched faction by factionID, seeing how Blizzard's SetWatchedFactionIndex() only works from 1 to GetNumFactions() I had to create a function.
However, my code isn't advancing properly past index 1, "Alliance" in my testbed. Oddly, the test prints are getting the correct factionID and name. I am missing something, and can't spot it. I don't think it matters that this code is for Classic, by all accounts it should work for Retail as well, except my comparison tables that return the factionID are based on Classic's UIMapIDs, which are not the same for both versions. The first print's output is "Stormwind" because that is where my toon is, while the second's output is "1", which is not correct. Based on my low level and lack of world exploration, the index should be "5" for Stormwind. Further testing from other print outputs does indicate that the factionID 1453 is correct, and matching for Stormwind. Lua Code:
|
It occurs to me to post more code, so this is my entire opening and closing of faction headers, plus setting of the faction by factionID. If anyone wants to see all of the code, I'll be happy to post that too.
Lua Code:
|
It seems like the line:
Code:
local name, _, standingID, _, _, _, _, _, isHeader, _, _, isWatched, _, factionID = GetFactionInfoByID(id) Code:
local name, _, standingID, _, _, _, _, _, isHeader, _, _, isWatched, _, factionID = GetFactionInfo(i) |
Vrul, yes, that's probably a bug, though upon testing walking from Stormwind City to Elwynn Forest, the UIMapIDs sync, but the watched rep is now printing nothing. Hm, progress?
Lua Code:
|
Code:
if type(id) == "table" then id = tonumber(id) end |
I'll comment it out for now. Eventually that line is for when I pass subzone strings via a table for those smaller areas that have a different associated faction than the main zone.
I thought that if the type wasn't a table, the line would do nothing. Maybe it does, so I'll test by commenting it out. |
Commenting it out still doesn't fix the issue. The lines
Code:
self:Print("DEBUG: SetWatchedFactionByFactionID name:", name) That means the code isn't even looping, right? |
Quote:
|
See what you get with:
lua Code:
|
Quote:
Taking the else break part was the fix, huh? |
break stops the loop.
You stop the loop if id ~= factionID but you want to stop it when you found the correct id. Lua Code:
|
Quote:
|
All times are GMT -6. The time now is 03:10 PM. |
vBulletin © 2024, Jelsoft Enterprises Ltd
© 2004 - 2022 MMOUI