Register forum user name Search FAQ

Gammon Forum

Notice: Any messages purporting to come from this site telling you that your password has expired, or that you need to verify your details, confirm your email, resolve issues, making threats, or asking for money, are spam. We do not email users with any such messages. If you have lost your password you can obtain a new one by using the password reset link.

Due to spam on this forum, all posts now need moderator approval.

 Entire forum ➜ MUSHclient ➜ Plugins ➜ Icon Bar / Action Bar- update button text from alias

Icon Bar / Action Bar- update button text from alias

You need to log onto the forum to reply or create new threads.

  Refresh page


Posted by Aardwanderer   (11 posts)  Bio
Date Thu 26 Mar 2026 11:58 PM (UTC)

Amended on Fri 27 Mar 2026 12:07 PM (UTC) by Aardwanderer

Message
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.
Top

Posted by Fiendish   USA  (2,557 posts)  Bio   Global Moderator
Date Reply #1 on Fri 27 Mar 2026 06:17 PM (UTC)

Amended on Fri 27 Mar 2026 06:19 PM (UTC) by Fiendish

Message
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?

https://github.com/fiendish/aardwolfclientpackage
Top

Posted by Aardwanderer   (11 posts)  Bio
Date Reply #2 on Fri 27 Mar 2026 07:21 PM (UTC)

Amended on Fri 27 Mar 2026 09:31 PM (UTC) by Aardwanderer

Message
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!
Top

Posted by Fiendish   USA  (2,557 posts)  Bio   Global Moderator
Date Reply #3 on Sat 28 Mar 2026 11:23 PM (UTC)

Amended on Sat 28 Mar 2026 11:25 PM (UTC) by Fiendish

Message
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.

https://github.com/fiendish/aardwolfclientpackage
Top

Posted by Shadowfyr   USA  (1,792 posts)  Bio
Date Reply #4 on Sun 29 Mar 2026 01:06 AM (UTC)
Message
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
Top

Posted by Aardwanderer   (11 posts)  Bio
Date Reply #5 on Sun 29 Mar 2026 05:57 PM (UTC)
Message
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!
Top

The dates and times for posts above are shown in Universal Co-ordinated Time (UTC).

To show them in your local time you can join the forum, and then set the 'time correction' field in your profile to the number of hours difference between your location and UTC time.


1,088 views.

You need to log onto the forum to reply or create new threads.

  Refresh page

Go to topic:           Search the forum


[Go to top] top

Information and images on this site are licensed under the Creative Commons Attribution 3.0 Australia License unless stated otherwise.