Should be simple - seems it's not (for me anyway) - ESOUI
Thread Tools Display Modes
07/17/18, 02:13 PM   #1
Join Date: Aug 2015
Posts: 6
Should be simple - seems it's not (for me anyway)

I am having trouble understanding the interactions between xml and lua. I have a control:

    <TopLevelControl name="WhichSetIndicator" mouseEnabled="true" movable="true" clampedToScreen="true">
      <Dimensions x="250" y="25" />
      <Anchor point="BOTTOM" relativeTo="GuiRoot" relativePoint="CENTER" offsetY="-20" />

        <Label name="$(parent)Label" width="250" height="25" font="ZoFontWinH1" inheritAlpha="true" color="FF0000"
            wrapMode="TRUNCATE" verticalAlignment="TOP" horizontalAlignment="CENTER" text="Main Weapon Set!">
          <Anchor point="TOP" relativeTo="$(parent)" relativePoint="TOP" />
I would like to change the 'text' element during a keypress event which I already have working. I just can't find the correct way to change the text. I would imagine I could do something like this:

function WhichSet.OnActionBarChange(event, actionbar)
	if WhichSet.whichActionBar ~= GetActiveWeaponPairInfo() then
		WhichSet.whichActionBar = GetActiveWeaponPairInfo()

	if WhichSet.whichActionBar == 1 then
		WhichSetAddonIndicator:SetText("Main weapon set!")
		WhichSetAddonIndicator:text("Secondary weapon set!")

As you might have guessed, the red lines do not work. Can someone help?
  Reply With Quote
07/17/18, 02:56 PM   #2
AddOn Author - Click to view addons
Join Date: Sep 2016
Posts: 657
Shouldn't you be writing to the label? Which would be WhichSetIndicatorLabel:SetText("test")
  Reply With Quote
07/17/18, 06:57 PM   #3
Dolgubon's Avatar
AddOn Author - Click to view addons
Join Date: Jan 2016
Posts: 369
Rhyono is correct: You should use WhichSetAddonIndicatorLabel.
If you look at the XML, you have name="WhichSetIndicator". So the game makes a TopLevelControl called WhichSetIndicator. WhichSetIndicator is then added to the global table, allowing you to call it using WhichSetIndicator in Lua code. Next, you have name="$(parent)Label". This tells the game to take the name of the parent (WhichSetIndicator:GetName()) and append Label to it (WhichSetIndicator:GetName().."Label") and make that the name of the Label. So then you can call it as WhichSetIndicatorLabel in Lua code. You can also do WhichSetIndicator:GetNamedChild("Label") which might be more readable. I'd also suggest zgoo (specifically, when you have it, do /zgoo WhichSetIndicator) which could help you in the future if you run into problems with UI design.
  Reply With Quote
07/18/18, 10:54 AM   #4
Join Date: Aug 2015
Posts: 6
Thank you so much for the insight. This should help a lot. I am new to this and have not yet read much LUA reference material. I was relying on previous programming experience in other languages. I guess I had better do my homework. Again, Thank you.
  Reply With Quote

ESOUI » Developer Discussions » Lua/XML Help » Should be simple - seems it's not (for me anyway)

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