Button Based on Spell Affects

Posted by Lilac on Wed 09 Apr 2025 03:28 PM — 19 posts, 25,783 views.

#0
I'm trying to work out how to make a visual cool down button based on one particular spell affect.

So it would display off, for example:


You are affected by the following spells:
Spell: alterform : modifies none by 0 for 49 cycles, (24 1/2 hours)


I'm not sure how to make this happen when the cycles/hours constantly changes, so it will need to continually evaluate it.


I'm a "no-grammer", unfortunately, and although I have seen the plugins section with buttons like this, I'm really not sure how to alter it to what I want.

Also, it doesn't necessarily have to be a button. Anything that in any way lets me visually know the status of that spell without typing "affects" would be fine by me. Status bar, or mini-window, or anything.
Amended on Wed 09 Apr 2025 03:33 PM by Lilac
Australia Forum Administrator #1
I have a post about buttons with cooldowns:

https://www.gammon.com.au/forum/?id=9359

You could modify that and change the way it reacts to the MUD info as appropriate. On that page there is even a mention of:


SetCooldown (4, 50) -- set button 4 to cooldown in 50 seconds


So, you could make a trigger to update the cooldown amount based on a trigger or timer.
#2
I've spent a couple hours messing with this with no luck. I tried to use AI to mess with it because I understand ZERO about scripting and plugins.

Near as I can tell the issue is that:

1.) I need this to evaluate time left without depending on when the condition is first activated, as its starting point.

2.) It should not need me to continually type "affects" to see where the spell timer is at.

It looks like this Plugin gets its information based upon a trigger "cast alterform", which I don't want. This isn't even even technically a spell, I type "alter" to make the change, so there's no "cast" involved.

I just need something to repeatedly and continually get the information from:

You are affected by the following spells:
Spell: alterform : modifies none by 0 for 343 cycles, (171 1/2 hours)


....and display it some place in my client where it's easily visible.
Amended on Fri 11 Apr 2025 12:09 AM by Lilac
Australia Forum Administrator #3
Quote:

2.) It should not need me to continually type "affects" to see where the spell timer is at.


Is it predictable once you see the message once? In other words, does 343 cycles (say) represent a fixed amount of time (eg. 20 minutes)?
#4
Near as I can figure out, a "cycle" is just a tick. I don't know how long a tick is, but people make tick timers; is there a way I can figure this out if necessary?
Australia Forum Administrator #5
Judging by your two examples, a cycle is half an hour.

Quote:

343 cycles, (171 1/2 hours)



171.5 / 343 = 0.5 hours


I did a text-based button in this thread:

https://www.gammon.com.au/forum/?id=15238

So in your case you could make a trigger like this:



<triggers>
  <trigger
   enabled="y"
   match="^Spell\: (?P&lt;spelltext&gt;(?P&lt;name&gt;.*?) \: modifies (.*?) by (.*?) for (?P&lt;cycles&gt;.*?) cycles)"
   regexp="y"
   send_to="12"
   sequence="100"
  >
  <send>

CallPlugin ("2f103c42b3356ee1bcac384b" , "MakeWindow" , "%&lt;name&gt;", "%&lt;spelltext&gt;", %&lt;cycles&gt; * 1800)

-- 1800 seconds in half an hour

</send>
  </trigger>
</triggers>


Template:pasting
For advice on how to copy the above, and paste it into MUSHclient, please see Pasting XML.


So, install the plugin mentioned in the linked post, and then trigger the info boxes to arrive by using the trigger above.
#6
Awesome! Eager to try it out! But when I click on your link for the button with cool downs, I get "This subject has not been approved and you are not the author of it."
Australia Forum Administrator #7
It should be OK now.
#8
So I've got miniwindows with times, but they don't seem to update on their own. They only change when I type affects again.

What am I missing?
Australia Forum Administrator #9
Do you mean, the timers don't count down? Make sure timers are enabled.

Or do you mean something else?
#10
I downloaded the plugin and imported it. I added the trigger. Timers are on. It doesn't update the time left unless I type "affects".
Australia Forum Administrator #11
Can you show the trigger please?

Template:copying
For advice on how to copy aliases, timers or triggers from within MUSHclient, and paste them into a forum message, please see Copying XML.
#12
<triggers>
<trigger
enabled="y"
match="^Spell\: (?P&lt;spelltext&gt;(?P&lt;name&gt;.*?) \: modifies (.*?) by (.*?) for (?P&lt;cycles&gt;.*?) cycles)"
regexp="y"
send_to="12"
sequence="100"
>
<send>

CallPlugin ("2f103c42b3356ee1bcac384b" , "MakeWindow" , "%&lt;name&gt;", "%&lt;spelltext&gt;", %&lt;cycles&gt; * 1800)

-- 1800 seconds in half an hour

</send>
</trigger>
</triggers>
Australia Forum Administrator #13
When I tried that with your test:


Spell: alterform : modifies none by 0 for 49 cycles, (24 1/2 hours)


I saw a box with this in it:


alterform : modifies none by 0 for 49 cycles (wait) 1d


49 times 0.5 hours is 24.5 hours, so the box shows "1d" (one day) which would eventually become 23 hours and count down every hour.
Australia Forum Administrator #14
Quote:

total_seconds = cycles * 41


Based on that, there are 41 seconds to a cycle, not 1800.

Maybe the earlier message refers to game time, not real time.

Try changing 1800 to 41.
#15
Fantastic, that change seems to be better reflective of the time frame. Thank you so much for your effort and patience on this one, I can't tell you how much I appreciate it.


So this script counts down on the hour? Is it possible to have it refresh on the half hour?

In a totally perfect would I'd like it to update in real time (with every tick that passes) but I don't know if that's unreasonable or not.

I want to be able to monitor it and catch the spell before it falls, but if the last real notification is one whole hour before, that's cumbersome.
Amended on Wed 16 Apr 2025 01:19 PM by Lilac
Australia Forum Administrator #16

It updates internally every second, however the display is rounded.

For example, if your cooldown is in 4 hours you don’t really care if it is 4 hours and 15 seconds do you?

The display works like this:

Over a day

Displays: 3d, 2d, 1d, etc.

Less than a day but more than an hour

Displays: 23h, 22h, 21h etc.

Less than an hour but more than a minute

Displays: 59m, 58m, 57m etc.

Less than a minute

Displays: 59s, 58s, 57s etc.


You could conceivably make the display change colour when time is almost up, for example change:

-- add the text
    WindowText (win, font_id, contents, MARGIN / 2, MARGIN / 2, 0, 0, ColourNameToRGB ("black"))

to:

    color = "black"
    if details.cooldown and details.cooldown < 60 and details.cooldown > 0 then
      color = "darkred"
    end -- if soon
    -- add the text
    WindowText (win, font_id, contents, MARGIN / 2, MARGIN / 2, 0, 0, color)
Amended on Wed 16 Apr 2025 08:56 PM by Nick Gammon
#17
Nick Gammon said:

It updates internally every second, however the display is rounded.

For example, if your cooldown is in 4 hours you don't really care if it is 4 hours and 15 seconds do you?



No, but I was thinking counting down the timer cycles in real time; so ticking down the cycles on the display, instead of the hour mark.

39 cycles, 38 cycles, so on.


I've also made note that it will ping other things (my MUD has random affects, which is fine to show), but the box doesn't disappear like it's supposed to when they're over, even if you type "affects" again and they're no longer in there.
Amended on Wed 16 Apr 2025 09:41 PM by Lilac
Australia Forum Administrator #18
As I mentioned on the page about the plugin you can delete the box.

https://www.gammon.com.au/forum/?id=15238&page=999


CallPlugin ("2f103c42b3356ee1bcac384b" , "RemoveWindow" , "quest")


You could amend that plugin to do the RemoveWindow function call whenever the time drops below zero.

As for the count-down, you could amend it to show cycles by dividing the number of seconds by 41, which would be the number of cycles.