Icon Bar / Action Bar- update button text from alias

Posted by Aardwanderer on Thu 26 Mar 2026 11:58 PM — 6 posts, 3,700 views.

#0
The Icon Bar plugin is amazing! I already have two icon bars modified and am now working on a third. For this one, I am hoping to update the text in different buttons (eg: button 1 goes to dungeon, but as I get to level 20, I want to go to village instead). My thought was to put a variable in the text="name", but it just displays as is.

--edited, see below for partial solution.

Here was my thought:


  <alias
   match="^ibname set(?<button_number>\d+) +(?<name>\w+)$"
   enabled="y"
   regexp="y"
   send_to="12"
   sequence="100"
  ><send>
      if "%1" == "1" then
        SetVariable("ibname1", "%2")
      elseif "%1" == "2" then
        SetVariable("ibname2", "%2")
      elseif "%1" == "3" then
        SetVariable("ibname3", "%2")
      elseif "%1" == "4" then
        SetVariable("ibname4", "%2")
      elseif "%1" == "5" then
        SetVariable("ibname5", "%2")
      else
        Note("Icon bar number: " .. "%1" .. " not set.")
      end --if
   </send>
  </alias>

  -- button 1
  {
  icon = nil,
  tooltip = "Update zone with: gtz <level> <zone>",  -- tooltip help text
  text = "GetVariable('ibname1')",
  send = "gotozone",  -- sends alias that updates to the favorite zone at the current level
  cooldown = 0,          -- cooldown time is 0 because it is set by a trigger
  sound = "chimes.wav",   -- sound to play when cast
  --done = function () end   -- what to do when done
  }, -- end of button 1

  -- button 2
  {
  icon = nil,
  tooltip = "Current highest level fire spell",  -- tooltip help text
  text = "GetVariable('firespell')",
  send = "cfs",  -- sends alias for highest level fire spell
  cooldown = 0,          -- cooldown time is 0 because it is set by a trigger
  sound = "chimes.wav",   -- sound to play when cast
  --done = function () end   -- what to do when done
  }, -- end of button 2


Is there a way to get the button text to change through use of an alias? It wouldn't have to be through the use of a variable, but that made the most sense to me since the variable already exists.

Thank you,

Aardwanderer

edit:
I was able to update the text by modifying the alias to change the table, buttons.


   <send>
      if "%1" == "1" then
        SetVariable("arwArea1", "%2")
        buttons[1].text = GetVariable("arwArea1")


Now I have two new issues 1) the name doesn't update until the button is clicked or the cooldown is started from a trigger 2) when MuchClient is closed, the updated variable will return to what is entered in the xml file.

Also, I think I changed one of the other windows, that I copied and modified, so it doesn't show the pie filling. How do I turn that back on? Right now I only see the number countdown.
Amended on Fri 27 Mar 2026 12:07 PM by Aardwanderer
USA Global Moderator #1
Quote:
the name doesn't update until the button is clicked or the cooldown is started from a trigger

You need to force the buttons to re-draw themselves. The easiest way would be to call OnPluginInstall() again after you change the button text value.

Quote:
When MuchClient is closed, the updated variable will return to what is entered in the xml file

You need to make the main button table construction in https://github.com/nickgammon/plugins/blob/55af9faf636bf15d25c86ee1bea10ec33bcbb79f/Icon_Bar.xml#L91-L116 also use your new arwArea# variables (with appropriate default fallback values if the variables aren't set yet).


Quote:
it doesn't show the pie filling. How do I turn that back on?

The cooldown pie filling is drawn by this WindowCircleOp image blend code https://github.com/nickgammon/plugins/blob/55af9faf636bf15d25c86ee1bea10ec33bcbb79f/Icon_Bar.xml#L344-L376

I notice that your button table has the cooldowns set to 0. Do you update those somewhere to be non-zero?
Amended on Fri 27 Mar 2026 06:19 PM by Fiendish
#2
Thank you for the quick response!

Adding OnPluginInstall() to the alias did the trick in updating the button name.

For keeping the variables up-to-date, would it make sense to add the new arwArea# variables to the OnPluginInstall() function?


Quote:
I notice that your button table has the cooldowns set to 0. Do you update those somewhere to be non-zero?


Yes, the cooldown is updated by a trigger. I did check to see what happens if the value is not 0, and that didn't change anything. What I see now is a numerical countdown (by minutes until under 1 minute, then seconds).

Thanks again!
Amended on Fri 27 Mar 2026 09:31 PM by Aardwanderer
USA Global Moderator #3
Quote:
For keeping the variables up-to-date, would it make sense to add the new arwArea# variables to the OnPluginInstall() function?

Minimally you need to change this code to use GetVariable with your new variables instead of what it does now to set up the text for the buttons during startup. https://github.com/nickgammon/plugins/blob/55af9faf636bf15d25c86ee1bea10ec33bcbb79f/Icon_Bar.xml#L91C1-L116

Putting that at the start of OnPluginInstall instead of outside might be reasonable but is optional.

I'd need to see what you've done in your plugin to identify why your cooldown gets no visual sweep.
Amended on Sat 28 Mar 2026 11:25 PM by Fiendish
USA #4
Personally, the "long term" solution, it seem to me, would be to alter the plugin so that the setting up of the buttons was in a function, like SetupButtons, then have OnPluginInstall call this as part of its operation. That way any changes that need to happen, in code, later, to update this information would just call SetupButtons. Or, what ever would be appropriate for a name. Haven't looked at the code, so not sure. This is just my first thought on it. Seems to me, its always better to have a method to update things "after" initial setup. But, that is just me and my tendency of thinking, "Huh... what might someone, including myself, want to do with this later?"

Not that I am not guilty of the same. Coding anything (including a character tracker for D&D I made a while back when I got bloody annoyed that existing ones didn't keep track of some things mine needed to) so that it supports maximal adjustability, instead of just as, "Eh.. This solves the problem, for now..", can be a massive pain. lol
#5
Fiendish, thanks for the feedback. I'll poke around the plugin to see if there's an option in there somewhere for turning the sweep on or off.

Shadowfyr, the plugin was made to be modular, so you could have one button or more by adding or removing the button info as in my first post. Due to my novice abilities in scripting/programming, I'm not sure how/if a function could be made to account for the addition or removal of buttons.

I like the idea of a function though, so maybe if I mull it around for a while, I'll be able to come up with something.

Thanks!