WoWInterface

WoWInterface (https://www.wowinterface.com/forums/index.php)
-   Lua/XML Help (https://www.wowinterface.com/forums/forumdisplay.php?f=16)
-   -   trying to call placeholderG a nil value (https://www.wowinterface.com/forums/showthread.php?t=59765)

fatrog 01-15-24 12:58 PM

trying to call placeholderG a nil value
 
Hello, I have a problem with this bit

Lua Code:
  1. local function GetMacroIDInfos(tt)
  2.     spellID = nil
  3.    
  4.     displayedName = placeholderG[tt:GetName().."TextLeft"..1]:GetText()
  5.     placeholder,placeholder,placeholder,placeholder,placeholder,placeholder,spellID = GetSpellInfo(displayedName)
  6.    
  7.     if spellID ~= nil then
  8.         SetNewLineWithID(tt,spellID)
  9.     end
  10. end
  11.  
  12. TooltipDataProcessor.AddTooltipPostCall(Enum.TooltipDataType.Macro, GetMacroIDInfos)

Apparently the placeholderG object is not filled properly. For instance, I did that for spells

Lua Code:
  1. local function GetSpellIDInfos(tt)
  2.     spellID = nil
  3.    
  4.     placeholder, spellID = TooltipUtil.GetDisplayedSpell(tt)
  5.     if spellID ~= nil then
  6.         SetNewLineWithID(tt,spellID)
  7.     end
  8. end
  9.  
  10. TooltipDataProcessor.AddTooltipPostCall(Enum.TooltipDataType.Spell, GetSpellIDInfos)

and it work like a charm.

Any idea what is happening here?

Fizzlemizz 01-15-24 01:24 PM

Quote:

Originally Posted by fatrog (Post 343181)
Any idea what is happening here?

No. You've given no indication where/how you're creating/filling the placeholderG table or, if you're expecting it to be filled by something else, the who/how of that. It's not a Blizzard thing as far as I can tell.

Maybe start by telling us where you got the idea to use placeholderG from?

Edit: it's probably a reference to the _G global table.
You should be able to use
Code:

displayedName = tt.TextLeft1:GetText()

fatrog 01-15-24 01:44 PM

To be honest, I can't remember when I started this so I have no idea where "placeholderG" comes from but I can assure you I didnt invented this name because it is not the style of naming I'm using.

Anyway, thank you :D it is clean and simple. I didn't knew I could access the macros titles just like this.

Fizzlemizz 01-15-24 01:50 PM

tt, in this case the the GameTooltip frame. Blizzard have been moving the requirement to use _G[sub-region name] over to frame keys since the introduction of the parentKey attribute in XML.

Kanegasi 01-15-24 01:51 PM

As Fizzlemizz mentioned, it's _G, which is the global table in Lua. At some point, the code you have, or the code you got from someone else, was subject to a replace all in an editor where they replaced the underscore character with "placeholder". Typical coding practices use the underscore as a throwaway object for function returns they don't want, but in the case of _G, it is part of the name of that object.


All times are GMT -6. The time now is 01:57 PM.

vBulletin © 2024, Jelsoft Enterprises Ltd
© 2004 - 2022 MMOUI