Thread Tools Display Modes
01-15-24, 12:58 PM   #1
fatrog
A Fallenroot Satyr
Join Date: Nov 2022
Posts: 21
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?
  Reply With Quote
01-15-24, 01:24 PM   #2
Fizzlemizz
I did that?
 
Fizzlemizz's Avatar
Premium Member
AddOn Author - Click to view addons
Join Date: Dec 2011
Posts: 1,879
Originally Posted by fatrog View Post
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()
__________________
Fizzlemizz
Maintainer of Discord Unit Frames and Discord Art.
Author of FauxMazzle, FauxMazzleHUD and Move Pad Plus.

Last edited by Fizzlemizz : 01-15-24 at 01:30 PM.
  Reply With Quote
01-15-24, 01:44 PM   #3
fatrog
A Fallenroot Satyr
Join Date: Nov 2022
Posts: 21
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 it is clean and simple. I didn't knew I could access the macros titles just like this.
  Reply With Quote
01-15-24, 01:50 PM   #4
Fizzlemizz
I did that?
 
Fizzlemizz's Avatar
Premium Member
AddOn Author - Click to view addons
Join Date: Dec 2011
Posts: 1,879
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.
__________________
Fizzlemizz
Maintainer of Discord Unit Frames and Discord Art.
Author of FauxMazzle, FauxMazzleHUD and Move Pad Plus.
  Reply With Quote
01-15-24, 01:51 PM   #5
Kanegasi
A Molten Giant
 
Kanegasi's Avatar
AddOn Author - Click to view addons
Join Date: Apr 2007
Posts: 666
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.
  Reply With Quote

WoWInterface » Developer Discussions » Lua/XML Help » trying to call placeholderG a nil value


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