Thread Tools Display Modes
05-24-21, 11:09 PM   #1
myrroddin
A Pyroguard Emberseer
 
myrroddin's Avatar
AddOn Author - Click to view addons
Join Date: Oct 2008
Posts: 1,240
Nil error for something I cannot track down

Attached is a zip of my WIP of RepByZone, as copying my Lua code will take up a lot of space in a thread. I do understand the error, but cannot explain what is causing it to happen. The variable that should have data is on line 141 of Core-Retail.lua, in the Onitialize function, and refreshed on line 6 of Options.lua just in case the user has changed something. Why Options.lua cannot see that variable, I don't know.

I need fresh eyes, methinks. The error dump is below.

Lua Code:
  1. 1x RepByZone\Options-Options.lua:77: bad argument #1 to 'format' (string expected, got nil)
  2. [string "=[C]"]: in function `format'
  3. [string "@RepByZone\Options-Options.lua"]:77: in function `member'
  4. [string "@Ace3\AceConfig-3.0-3\AceConfigDialog-3.0\AceConfigDialog-3.0-81.lua"]:221: in function <...nfig-3.0\AceConfigDialog-3.0\AceConfigDialog-3.0.lua:169>
  5. [string "@Ace3\AceConfig-3.0-3\AceConfigDialog-3.0\AceConfigDialog-3.0-81.lua"]:1211: in function <...nfig-3.0\AceConfigDialog-3.0\AceConfigDialog-3.0.lua:1121>
  6. [string "@Ace3\AceConfig-3.0-3\AceConfigDialog-3.0\AceConfigDialog-3.0-81.lua"]:1652: in function `FeedGroup'
  7. [string "@Ace3\AceConfig-3.0-3\AceConfigDialog-3.0\AceConfigDialog-3.0-81.lua"]:1577: in function <...nfig-3.0\AceConfigDialog-3.0\AceConfigDialog-3.0.lua:1561>
  8. [string "=[C]"]: ?
  9. [string "@Ace3\AceGUI-3.0\AceGUI-3.0-41.lua"]:72: in function <Ace3\AceGUI-3.0\AceGUI-3.0.lua:70>
  10. [string "@Ace3\AceGUI-3.0\AceGUI-3.0-41.lua"]:306: in function `Fire'
  11. [string "@Ace3\AceGUI-3.0-41\widgets\AceGUIContainer-TabGroup.lua"]:156: in function `SelectTab'
  12. [string "@Ace3\AceConfig-3.0-3\AceConfigDialog-3.0\AceConfigDialog-3.0-81.lua"]:1688: in function `FeedGroup'
  13. [string "@Ace3\AceConfig-3.0-3\AceConfigDialog-3.0\AceConfigDialog-3.0-81.lua"]:1932: in function `Open'
  14. [string "@RepByZone\Core-Retail.lua"]:196: in function `?'
  15. [string "@Ace3\AceConsole-3.0\AceConsole-3.0-7.lua"]:94: in function `?'
  16. [string "@FrameXML\ChatFrame.lua"]:5094: in function `ChatEdit_ParseText'
  17. [string "@FrameXML\ChatFrame.lua"]:4758: in function `ChatEdit_SendText'
  18. [string "@FrameXML\ChatFrame.lua"]:4794: in function <FrameXML\ChatFrame.lua:4790>
  19. [string "=[C]"]: in function `ChatEdit_OnEnterPressed'
  20. [string "*:OnEnterPressed"]:1: in function <[string "*:OnEnterPressed"]:1>
Attached Files
File Type: zip RepByZone.zip (187.3 KB, 128 views)
  Reply With Quote
05-24-21, 11:52 PM   #2
Fizzlemizz
I did that?
 
Fizzlemizz's Avatar
Premium Member
AddOn Author - Click to view addons
Join Date: Dec 2011
Posts: 1,871
As far as I can tell, in the set for useClassRep (Options.lua line 83) you have
Code:
self.racialRepID, self.racialRepName = self:GetRacialRep()
Is self:GetRacialRep() returning anything at this point?
__________________
Fizzlemizz
Maintainer of Discord Unit Frames and Discord Art.
Author of FauxMazzle, FauxMazzleHUD and Move Pad Plus.
  Reply With Quote
05-25-21, 12:17 AM   #3
myrroddin
A Pyroguard Emberseer
 
myrroddin's Avatar
AddOn Author - Click to view addons
Join Date: Oct 2008
Posts: 1,240
Hm. It did, but now it isn't showing in the options UI. I wonder what I did to cause that?
  Reply With Quote
05-25-21, 12:22 AM   #4
Fizzlemizz
I did that?
 
Fizzlemizz's Avatar
Premium Member
AddOn Author - Click to view addons
Join Date: Dec 2011
Posts: 1,871
You have the .zip in your previous post to undo whatever it was
__________________
Fizzlemizz
Maintainer of Discord Unit Frames and Discord Art.
Author of FauxMazzle, FauxMazzleHUD and Move Pad Plus.
  Reply With Quote
05-27-21, 12:26 AM   #5
myrroddin
A Pyroguard Emberseer
 
myrroddin's Avatar
AddOn Author - Click to view addons
Join Date: Oct 2008
Posts: 1,240
Okay, the nil error is because data is not ready when I assign variables. The trouble is that there is no logical reason why the data should not exist. I have tried all sorts of variations of my code, and I'm getting nowhere. What I should see in the options, from Options.lua which hasn't changed, is:
  • A toggle that is either a class or race reputation. The text would be the same for a Night Elf Demon Hunter because there is no class reputation. If you are a Night Elf Druid, the text should switch between Darnassus and Cenarion Circle.
  • There should be a menu list of the player's known factions, defaulting to either class or race faction unless the user changes the watched faction.
Neither of these are displaying and fire the error from my first post.

Below is the latest version of Core-Retail.lua.
Lua Code:
  1. local RepByZone = LibStub("AceAddon-3.0"):NewAddon("RepByZone", "AceEvent-3.0", "LibAboutPanel-2.0", "AceConsole-3.0")
  2. local L = LibStub("AceLocale-3.0"):GetLocale("RepByZone")
  3. local Dialog = LibStub("AceConfigDialog-3.0")
  4.  
  5. -- Local variables
  6. local db
  7. local isOnTaxi
  8. local instancesAndFactions
  9. local zonesAndFactions
  10. local subZonesAndFactions
  11.  
  12. -- Get the character's racial factionID and factionName
  13. function RepByZone:GetRacialRep()
  14.     -- Catch possible errors during initialization
  15.     local useClassRep
  16.     if self.db == nil then
  17.         useClassRep = true
  18.     else
  19.         useClassRep = self.db.profile.useClassRep
  20.     end
  21.  
  22.     local _, playerRace = UnitRace("player")
  23.     local H = UnitFactionGroup("player") == "Horde"
  24.     local A = UnitFactionGroup("player") == "Alliance"
  25.     local whichID, whichName
  26.  
  27.     local racialRepID = playerRace == "Dwarf" and 47 -- Ironforge
  28.     or playerRace == "Gnome" and 54 -- Gnomeregan
  29.     or playerRace == "Human" and 72 -- Stormwind
  30.     or playerRace == "NightElf" and 69 -- Darnassus
  31.     or playerRace == "Orc" and 76 -- Orgrimmar
  32.     or playerRace == "Tauren" and 81 -- Thunder Bluff
  33.     or playerRace == "Troll" and 530 -- Darkspear Trolls
  34.     or playerRace == "Scourge" and 68 -- Undercity
  35.     or playerRace == "Goblin" and 1133 -- Bilgewater Cartel
  36.     or playerRace == "Draenei" and 930 -- Exodar
  37.     or playerRace == "Worgen" and 1134 -- Gilneas
  38.     or playerRace == "BloodElf" and 911 -- Silvermoon City
  39.     or playerRace == "Pandaren" and (A and 1353 or H and 1352 or 1216) -- Tushui Pandaren or Huojin Pandaren or Shang Xi's Academy
  40.     or playerRace == "HighmountainTauren" and 1828 or 81 -- Highmountain Tribe or Thunder Bluff
  41.     or playerRace == "VoidElf" and 2170 or 69 -- Argussian Reach or Danassus
  42.     or playerRace == "Mechagnome" and 2391 or 54 -- Rustbolt Resistance or Gnomeregan
  43.     or playerRace == "Vulpera" and 2158 or 76 -- Voldunai or Orgrimmar
  44.     or playerRace == "KulTiran" and 2160 or 72 -- Proudmoore Admiralty or Stormwind
  45.     or playerRace == "ZandalariTroll" and 2103 or 530 -- Zandalari Empire or Darkspear Trolls
  46.     or playerRace == "Nightborne" and 1859 or 911 -- The Nightfallen or Silvermoon City
  47.     or playerRace == "MagharOrc" and 941 or 76 -- The Mag'har or Orgrimmar
  48.     or playerRace == "DarkIronDwarf" and 59 or 47 -- Thorium Brotherhood or Ironforge
  49.     or playerRace == "LightforgedDraenei" and 2165 or 930 -- Army of the Light or Exodar
  50.  
  51.     -- Classes have factions
  52.     local _, classFileName = UnitClass("player")
  53.     local classRepID = classFileName == "ROGUE" and 349 -- Ravenholdt
  54.     or classFileName == "DRUID" and 609 -- Cenarion Circle
  55.     or classFileName == "SHAMAN" and 1135 -- The Earthen Ring
  56.     or classFileName == "DEATHKNIGHT" and 1098 -- Knights of the Ebon Blade
  57.     or classFileName == "MAGE" and 1090 -- Kirin Tor
  58.     or classFileName == "MONK" and 1341 -- The August Celestials
  59.  
  60.     self:OpenAllFactionHeaders()
  61.     -- Check if the player has discovered the race faction
  62.     local function CheckRace()
  63.         for i = 1, GetNumFactions() do
  64.             local name, _, _, _, _, _, _, _, isHeader, _, _, _, _, factionID = GetFactionInfo(i)
  65.             if name and not isHeader then
  66.                 if factionID == racialRepID then
  67.                     whichID, whichName = factionID, name
  68.                 end
  69.             end
  70.         end
  71.     end
  72.     CheckRace()
  73.  
  74.     -- Check if the player has discoverd the class faction
  75.     if useClassRep then
  76.         for i = 1, GetNumFactions() do
  77.             local name, _, _, _, _, _, _, _, isHeader, _, _, _, _, factionID = GetFactionInfo(i)
  78.             if name and not isHeader then
  79.                 if factionID == classRepID then
  80.                     whichID, whichName = factionID, name
  81.                 end
  82.             end
  83.         end
  84.         -- Either no class faction or player hasn't discovered it yet
  85.         if not whichID then
  86.             CheckRace()
  87.         end
  88.     end
  89.     self:CloseAllFactionHeaders()
  90.  
  91.     self.racialRepID = useClassRep and classRepID or racialRepID
  92.     self.racialRepName = GetFactionInfoByID(self.racialRepID)
  93.     return whichID, whichName
  94. end
  95.  
  96. -- Return a table of defaul SV values
  97. local defaults = {
  98.     profile = {
  99.         enabled = true,
  100.         watchSubZones = true,
  101.         verbose = true,
  102.         watchOnTaxi = false,
  103.         useClassRep = true,
  104.     }
  105. }
  106.  
  107. function RepByZone:OnInitialize()
  108.     self.db = LibStub("AceDB-3.0"):New("RepByZoneDB", defaults)
  109.     self.db.RegisterCallback(self, "OnProfileChanged", "RefreshConfig")
  110.     self.db.RegisterCallback(self, "OnProfileCopied", "RefreshConfig")
  111.     self.db.RegisterCallback(self, "OnProfileReset", "RefreshConfig")
  112.     db = self.db.profile
  113.    
  114.     self:SetEnabledState(db.enabled)
  115.  
  116.     if db.watchedRepID == nil then
  117.         db.watchedRepID, db.watchedRepName = self:GetRacialRep()
  118.     end
  119.  
  120.     -- Populate variables
  121.     isOnTaxi = UnitOnTaxi("player")
  122.     self.covenantRepID = self:CovenantToFactionID()
  123.     self.racialRepID, self.racialRepName = self:GetRacialRep()
  124.  
  125.     -- Cache instance, zone, and subzone data
  126.     instancesAndFactions = self:InstancesAndFactionList()
  127.     zonesAndFactions = self:ZoneAndFactionList()
  128.     subZonesAndFactions = self:SubZonesAndFactions()
  129.  
  130.     local options = self:GetOptions() -- Options.lua
  131.     options.args.profiles = LibStub("AceDBOptions-3.0"):GetOptionsTable(self.db)
  132.  
  133.     -- Support for LibAboutPanel-2.0
  134.     options.args.aboutTab = self:AboutOptionsTable("RepByZone")
  135.     options.args.aboutTab.order = -1 -- -1 means "put it last"
  136.  
  137.     -- Register your options with AceConfigRegistry
  138.     LibStub("AceConfig-3.0"):RegisterOptionsTable("RepByZone", options)
  139.  
  140.     -- Add options to Interface/AddOns
  141.     self.optionsFrame = Dialog:AddToBlizOptions("RepByZone", "RepByZone")
  142.  
  143.     -- Create slash commands
  144.     self:RegisterChatCommand("repbyzone", "SlashHandler")
  145.     self:RegisterChatCommand("rbz", "SlashHandler")
  146. end
  147.  
  148. function RepByZone:OnEnable()
  149.     -- All events that deal with entering a new zone or subzone are handled with the same function
  150.     self:RegisterEvent("ZONE_CHANGED_NEW_AREA", "SwitchedZones")
  151.     self:RegisterEvent("ZONE_CHANGED", "SwitchedZones")
  152.     self:RegisterEvent("ZONE_CHANGED_INDOORS", "SwitchedZones")
  153.     -- If player is in combat, close options panel and exit out of command line
  154.     self:RegisterEvent("PLAYER_REGEN_DISABLED", "InCombat")
  155.     -- If the player loses or gains control of the character, it is one of the signs of taxi use
  156.     self:RegisterEvent("PLAYER_CONTROL_LOST", "CheckTaxi")
  157.     self:RegisterEvent("PLAYER_CONTROL_GAINED", "CheckTaxi")
  158.     self:RegisterEvent("PLAYER_ENTERING_WORLD", "LoginReload") -- Set watched faction when the player first loads into the game
  159.     if UnitFactionGroup("player") == nil then
  160.         self:RegisterEvent("NEUTRAL_FACTION_SELECT_RESULT", "CheckPandaren")
  161.     end
  162.     self:RegisterEvent("COVENANT_CHOSEN", "JoinedCovenant")
  163.  
  164.     -- Populate variables
  165.     isOnTaxi = UnitOnTaxi("player")
  166.     self.covenantRepID = self:CovenantToFactionID()
  167.     self.racialRepID, self.racialRepName = self:GetRacialRep()
  168. end
  169.  
  170. function RepByZone:OnDisable()
  171.     -- Stop watching most events if RBZ is disabled
  172.     self:UnregisterEvent("ZONE_CHANGED_NEW_AREA")
  173.     self:UnregisterEvent("ZONE_CHANGED")
  174.     self:UnregisterEvent("ZONE_CHANGED_INDOORS")
  175.     self:UnregisterEvent("PLAYER_CONTROL_LOST")
  176.     self:UnregisterEvent("PLAYER_CONTROL_GAINED")
  177.     self:UnregisterEvent("PLAYER_ENTERING_WORLD")
  178.     self:UnregisterEvent("NEUTRAL_FACTION_SELECT_RESULT")
  179.     self:UnregisterEvent("COVENANT_CHOSEN")
  180.  
  181.     -- Wipe variables when RBZ is disabled
  182.     isOnTaxi = nil
  183. end
  184.  
  185. function RepByZone:SlashHandler()
  186.     -- Check if player is in combat, exit out and close options panels if that's the case
  187.     self:InCombat()
  188.  
  189.     -- Close option panel if opened, otherwise open option panel
  190.     if Dialog.OpenFrames["RepByZone"] then
  191.         Dialog:Close("RepByZone")
  192.     else
  193.         Dialog:Open("RepByZone")
  194.     end
  195. end
  196.  
  197. function RepByZone:RefreshConfig(event, database, ...)
  198.     db = self.db.profile
  199.     self.racialRepID, self.racialRepName = self:GetRacialRep()
  200. end
  201.  
  202. ------------------- Event handlers starts here --------------------
  203. function RepByZone:InCombat()
  204.     if UnitAffectingCombat("player") then
  205.         if Dialog.OpenFrames["RepByZone"] then
  206.             Dialog:Close("RepByZone")
  207.         end
  208.         return
  209.     end
  210. end
  211.  
  212. function RepByZone:CheckTaxi()
  213.     isOnTaxi = UnitOnTaxi("player")
  214. end
  215.  
  216. function RepByZone:LoginReload(event, isInitialLogin, isReloadingUi)
  217.     self:SwitchedZones()
  218. end
  219.  
  220. local covenantReps = {
  221.     [Enum.CovenantType.Kyrian] = 2407, -- The Ascended
  222.     [Enum.CovenantType.Venthyr] = 2413, -- Court of Harvesters
  223.     [Enum.CovenantType.NightFae] = 2422, -- Night Fae
  224.     [Enum.CovenantType.Necrolord] = 2410, -- The Undying Army
  225. }
  226.  
  227. function RepByZone:CovenantToFactionID()
  228.     local id = C_Covenants.GetActiveCovenantID()
  229.     return covenantReps[id]
  230. end
  231.  
  232. function RepByZone:JoinedCovenant(event, covenantID)
  233.     self.covenantRepID = self:CovenantToFactionID()
  234.     self:SwitchedZones()
  235. end
  236.  
  237. function RepByZone:CheckPandaren(event, success)
  238.     if success then
  239.         local A = UnitFactionGroup("player") == "Alliance" and ALLIANCE
  240.         local H = UnitFactionGroup("player") == "Horde" and HORDE
  241.         if UnitFactionGroup("player") ~= nil then
  242.             self.racialRepID, self.racialRepName = self:GetRacialRep()
  243.             if db.watchedRepID == 1216 then
  244.                 db.watchedRepID, db.watchedRepName = self:GetRacialRep()
  245.                 self:Print(L["You have joined the faction %s, switching watched saved variable to %s."]:format(A or H, db.watchedRepName))
  246.             end
  247.             self:SwitchedZones()
  248.             self:UnregisterEvent(event)
  249.         end
  250.     end
  251. end
  252.  
  253. -------------------- Reputation code starts here --------------------
  254. local repsCollapsed = {} -- Obey user's settings about headers opened or closed
  255. -- Open all faction headers
  256. function RepByZone:OpenAllFactionHeaders()
  257.     local i = 1
  258.     while i <= GetNumFactions() do
  259.         local name, _, _, _, _, _, _, _, isHeader, isCollapsed = GetFactionInfo(i)
  260.         if isHeader then
  261.             repsCollapsed[name] = isCollapsed
  262.             if name == FACTION_INACTIVE then
  263.                 if not isCollapsed then
  264.                     CollapseFactionHeader(i)
  265.                 end
  266.                 break
  267.             elseif isCollapsed then
  268.                 ExpandFactionHeader(i)
  269.             end
  270.         end
  271.         i = i + 1
  272.     end
  273. end
  274.  
  275. -- Close all faction headers
  276. function RepByZone:CloseAllFactionHeaders()
  277.     local i = 1
  278.     while i <= GetNumFactions() do
  279.         local name, _, _, _, _, _, _, _, isHeader, isCollapsed = GetFactionInfo(i)
  280.         if isHeader then
  281.             if isCollapsed and not repsCollapsed[name] then
  282.                 ExpandFactionHeader(i)
  283.             elseif repsCollapsed[name] and not isCollapsed then
  284.                 CollapseFactionHeader(i)
  285.             end
  286.         end
  287.         i = i + 1
  288.     end
  289.     wipe(repsCollapsed)
  290. end
  291.  
  292. function RepByZone:GetAllFactions()
  293.     -- Will not return factions the user has marked as inactive
  294.     self:OpenAllFactionHeaders()
  295.     local factionList = {}
  296.  
  297.     for i = 1, GetNumFactions() do
  298.         local name, _, _, _, _, _, _, _, isHeader, _, _, _, _, factionID = GetFactionInfo(i)
  299.         if not isHeader then
  300.             factionList[factionID] = name
  301.         end
  302.     end
  303.     factionList["0-none"] = NONE
  304.  
  305.     self:CloseAllFactionHeaders()
  306.     return factionList
  307. end
  308.  
  309. -- Blizzard sets watched faction by index, not by factionID so create our own API
  310. function RepByZone:SetWatchedFactionByFactionID(id)
  311.     if type(id) ~= "number" then return end
  312.  
  313.     self:OpenAllFactionHeaders()
  314.     for i = 1, GetNumFactions() do
  315.         local name, _, standingID, _, _, _, _, _, isHeader, _, _, isWatched, _, factionID = GetFactionInfo(i)
  316.         if id == factionID then
  317.             if not isWatched then
  318.                 SetWatchedFactionIndex(i)
  319.                 if db.verbose then
  320.                     self:Print(L["Now watching %s"]:format(name))
  321.                 end
  322.             end
  323.             self:CloseAllFactionHeaders()
  324.             return name, id
  325.         end
  326.     end
  327.     self:CloseAllFactionHeaders()
  328. end
  329.  
  330. -------------------- Watched faction code starts here --------------------
  331. -- Table to localize subzones that Blizzard does not provide areaIDs
  332. local CitySubZonesAndFactions = CitySubZonesAndFactions or {
  333.     -- ["Subzone"] = factionID
  334.     ["Aldor Rise"] = 932, -- The Aldor
  335.     ["Deeprun Tram"] = 72, -- Stormwind
  336.     ["Dwarven District"] = 47, -- Ironforge
  337.     ["Scryer's Tier"] = 934, -- The Scryers
  338.     ["Shrine of Unending Light"] = 932, -- The Aldor
  339.     ["The Salty Sailor Tavern"] = 21, -- Booty Bay
  340.     ["The Seer's Library"] = 934, -- The Scryers
  341.     ["Tinker Town"] = 54, -- Gnomeregan Exiles
  342.     ["Valley of Spirits"] = 530, -- Darkspear Trolls
  343.     ["Valley of Wisdom"] = 81, -- Thunder Bluff
  344. }
  345.  
  346. -- Player switched zones, subzones, or instances, set watched faction
  347. function RepByZone:SwitchedZones()
  348.     if isOnTaxi then
  349.         if not db.watchOnTaxi then
  350.             -- On taxi but don't switch
  351.             return
  352.         end
  353.     end
  354.  
  355.     local faction -- Predefine the variable for later use like tabards and bodyguards. Still need it now, however
  356.     local inInstance = IsInInstance() and select(8, GetInstanceInfo())
  357.     local subZone = GetMinimapZoneText()
  358.  
  359.     if inInstance then
  360.         -- Apply instance data
  361.         for instanceID, factionID in pairs(instancesAndFactions) do
  362.             if instanceID == inInstance then
  363.                 if self:SetWatchedFactionByFactionID(factionID) then
  364.                     return
  365.                 end
  366.             end
  367.         end
  368.         -- Some instances have subzone data
  369.         if db.watchSubZones then
  370.             -- Blizzard provided areaIDs
  371.             for areaID, factionID in pairs(subZonesAndFactions) do
  372.                 if C_Map.GetAreaInfo(areaID) == subZone then
  373.                     if self:SetWatchedFactionByFactionID(factionID) then
  374.                         return
  375.                     end
  376.                 end
  377.             end
  378.             -- Our localized missing Blizzard areaIDs
  379.             for areaName, factionID in pairs(CitySubZonesAndFactions) do
  380.                 if L[areaName] == subZone then
  381.                     if self:SetWatchedFactionByFactionID(factionID) then
  382.                         return
  383.                     end
  384.                 end
  385.             end
  386.         end
  387.     else
  388.         -- Apply world zone data
  389.         local UImapID = C_Map.GetBestMapForUnit("player")
  390.         for zoneID, factionID in pairs(zonesAndFactions) do
  391.             if zoneID == UImapID then
  392.                 if self:SetWatchedFactionByFactionID(factionID) then
  393.                     return
  394.                 end
  395.             end
  396.         end
  397.         -- Apply subzone data
  398.         if db.watchSubZones then
  399.             -- Blizzard provided areaIDs
  400.             for areaID, factionID in pairs(subZonesAndFactions) do
  401.                 if C_Map.GetAreaInfo(areaID) == subZone then
  402.                     if self:SetWatchedFactionByFactionID(factionID) then
  403.                         return
  404.                     end
  405.                 end
  406.             end
  407.             -- Our localized missing Blizzard areaIDs
  408.             for areaName, factionID in pairs(CitySubZonesAndFactions) do
  409.                 if L[areaName] == subZone then
  410.                     if self:SetWatchedFactionByFactionID(factionID) then
  411.                         return
  412.                     end
  413.                 end
  414.             end
  415.         end
  416.     end
  417.  
  418.     -- If no data is found, use default watched faction or race/class faction
  419.     faction = db.watchedRepID or self.racialRepID
  420.     if not self:SetWatchedFactionByFactionID(faction) then
  421.         -- Player does not want a default watched faction
  422.         SetWatchedFactionIndex(0) -- Clear watched faction
  423.     end
  424. end
  Reply With Quote
05-27-21, 12:44 PM   #6
Fizzlemizz
I did that?
 
Fizzlemizz's Avatar
Premium Member
AddOn Author - Click to view addons
Join Date: Dec 2011
Posts: 1,871
Have you checked for the obvious things like:

Is there a chance the character has a self.db but not a self.db.profile.useClassRep making local useClassRep nil in RepByZoneGetRacialRep()?
__________________
Fizzlemizz
Maintainer of Discord Unit Frames and Discord Art.
Author of FauxMazzle, FauxMazzleHUD and Move Pad Plus.
  Reply With Quote
05-27-21, 02:58 PM   #7
myrroddin
A Pyroguard Emberseer
 
myrroddin's Avatar
AddOn Author - Click to view addons
Join Date: Oct 2008
Posts: 1,240
I have not. I will test that next.
  Reply With Quote
05-27-21, 05:30 PM   #8
sezz
A Chromatic Dragonspawn
AddOn Author - Click to view addons
Join Date: Apr 2008
Posts: 158
GetNumFactions() returns 0 at the time you're calling it, C_Covenants.GetActiveCovenantID() aswell.

Maybe you could get all the faction data in OnEnable instead? I think AceAddon's OnEnable is PLAYER_LOGIN, which should be fine (you also avoid running code that isn't needed when the user has disabled the addon ingame).
  Reply With Quote
05-31-21, 03:04 AM   #9
myrroddin
A Pyroguard Emberseer
 
myrroddin's Avatar
AddOn Author - Click to view addons
Join Date: Oct 2008
Posts: 1,240
Originally Posted by sezz View Post
GetNumFactions() returns 0 at the time you're calling it, C_Covenants.GetActiveCovenantID() aswell.

Maybe you could get all the faction data in OnEnable instead? I think AceAddon's OnEnable is PLAYER_LOGIN, which should be fine (you also avoid running code that isn't needed when the user has disabled the addon ingame).
Good to know. I did solve the other issue, with the name being nil. I'll check my code to see where I can adjust GetNumFactions() and C_Covenants.GetActiveCovenantID().
  Reply With Quote
06-03-21, 01:17 AM   #10
myrroddin
A Pyroguard Emberseer
 
myrroddin's Avatar
AddOn Author - Click to view addons
Join Date: Oct 2008
Posts: 1,240
Thank you good people for the helpful hints. Everything is back to working condition with RepByZone 1.19.5, and now I'm doing data entry again.
  Reply With Quote

WoWInterface » Developer Discussions » Lua/XML Help » Nil error for something I cannot track down

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off