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 ➜ General ➜ Adding a debuff timer to the status bar that updates every second.

Adding a debuff timer to the status bar that updates every second.

It is now over 60 days since the last post. This thread is closed.     Refresh page


Posted by Shinowa   (4 posts)  Bio
Date Sun 17 Apr 2011 03:58 PM (UTC)
Message
Hello everyone, I'm new to MUSHclient and new to LUA and I would like a bit of direction to accomplish a task!

I would like to cast a debuff on a target, have that debuff landing trigger a timer on my status bar that ticks down the seconds til the debuff wears off.

I did this in another mud client by creating a trigger that set a variable "HiltDuration" to 33, it then set off a while loop that waited 1 second, then added -1 to the variable, and cycled until 0, at which point it removed the debuff displayed from my status bar.

Here's the landing message...
"You deftly slam the pommel of your weapon into {&HiltTarget}'s hand, impairing his ability to parry."

Here's the "send" of the trigger...
#T+ Hilt [this line adds the debuff to the status bar]
#VAR HiltDur 33 [this line sets the duration to 33]
#WHILE (@HiltDur >= 0) {#WAIT 1000;#IF (@HiltDur = 0) { #T- Hilt } {#ADD HiltDur -1}} [this line has the while loop that updates the variable and removes the debuff from the status bar when it hits 0]

Curious how the status bar updates. Is it whenever a variable on it is updated, or like every second, or what?
Top

Posted by Nick Gammon   Australia  (23,133 posts)  Bio   Forum Administrator
Date Reply #1 on Sun 17 Apr 2011 11:04 PM (UTC)

Amended on Sun 17 Apr 2011 11:05 PM (UTC) by Nick Gammon

Message
The status bar updates when you tell it to.

Based on the ideas here:

http://www.gammon.com.au/forum/?id=4956

This trigger will do it for you:


<triggers>
  <trigger
   custom_colour="2"
   enabled="y"
   expand_variables="y"
   match="You deftly slam the pommel of your weapon into @HiltTarget's hand, impairing his ability to parry."
   send_to="12"
   sequence="100"
  >
  <send>

require "wait"

require "wait"
wait.make (function ()

  for i = 33, 2, -1 do
    SetStatus (string.format ("Parry debuf expires in %i seconds", i))
    wait.time (1)
  end -- for
  
  SetStatus (string.format ("Parry debuf EXPIRING NOW!", i))
  wait.time (1)

  SetStatus ("Ready")

end) 

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


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


You need to have set up the variable HiltTarget which can be done in various ways.

- Nick Gammon

www.gammon.com.au, www.mushclient.com
Top

Posted by Shinowa   (4 posts)  Bio
Date Reply #2 on Wed 20 Apr 2011 03:11 AM (UTC)
Message
Very much appreciated, worked like a charm. I've tried to expand on it a bit and failed, but can't quite find my answers. I want to be able to have more than one debuff on the status bar and them not to alternate between which one it shows.

Here's how I changed the initial trigger.

<triggers>
  <trigger
   custom_colour="2"
   enabled="y"
   expand_variables="y"
   match="You deftly slam the pommel of your weapon into *'s hand, impairing his ability to parry."
   send_to="12"
   sequence="100"
  >
  <send> 
  
  SetVariable ("HiltDur", "33") 
  SetVariable ("HiltTar", "%1")

  require "wait"

  require "wait"
  wait.make (function ()

    for i = 33, 2, -1 do
      SetVariable ("HiltDur", "%i")
      wait.time (1)
    end -- for
  
   end) 


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


The first issue is that it is literally saving '%i' as the variable rather than what i's value is in this loop. Don't understand the actual use of %i I guess, is it only in a string output?

Next, I figured I could make a timer to update the status every second ... to where it shows like this ...

Hilt: 27 Rough: 30 Garotte: 33 ECT.

I tried something like this inside the send section of a timer with no luck.


SetStatus ("Hilt: ", GetVariable("HiltDur"),  "Rough: ", GetVariable("RoughDur"))
Top

Posted by Nick Gammon   Australia  (23,133 posts)  Bio   Forum Administrator
Date Reply #3 on Wed 20 Apr 2011 05:29 AM (UTC)
Message
Just change that loop to be:


 for i = 33, 2, -1 do
      SetVariable ("HiltDur", i)
      wait.time (1)
    end -- for



That is, the current value of i.

The other thing you did should work, in what way did it not?

- Nick Gammon

www.gammon.com.au, www.mushclient.com
Top

Posted by Shinowa   (4 posts)  Bio
Date Reply #4 on Thu 21 Apr 2011 12:21 AM (UTC)
Message
The problem was I was sending the line to the mud, instead of to script. I'm slowly learning heh. Thanks.
Top

Posted by forral   USA  (79 posts)  Bio
Date Reply #5 on Fri 06 May 2011 01:05 AM (UTC)
Message
Nick,

Could this be expanded to have multiple timers running at the same time?

For instance, I want to make a script such that when I launch of volley of attacks at a ship, it counts down the corresponding time until the next volley is available. Specifically, when I launch the fire-launcher, I have to wait 14 seconds between volleys, so I'd need a 14 second timer.

And then could the reverse be applied to keep track of spellups/buffs like aardwolf does? If I cast "poison" on an enemy, and I know its duration, I could have a script alert me with a sound or otherwise that, "Hey, you need to re-cast poison on this player".
Top

Posted by Nick Gammon   Australia  (23,133 posts)  Bio   Forum Administrator
Date Reply #6 on Fri 06 May 2011 05:25 AM (UTC)
Message
There is no problem with multiple timers. But you need to figure out where to put the info (after all there is only one status line).

You may find this post helpful:

Template:post=9359 Please see the forum thread: http://gammon.com.au/forum/?id=9359.


That describes buttons with cooldown timers on them.

- Nick Gammon

www.gammon.com.au, www.mushclient.com
Top

Posted by Shinowa   (4 posts)  Bio
Date Reply #7 on Tue 10 May 2011 02:28 AM (UTC)
Message
I have a trigger like this for 3 main skills so far, and I created one timer to display them all to the status bar..


<timers>
  <timer enabled="y" second="1.00" offset_second="0.00"    send_to="12"
omit_from_log="y" >
  <send>SetStatus ("  Hilt: ", GetVariable("HiltDur"), "  ", "  Rough: ", GetVariable("RoughDur"), "  ", "  Garotte: ", GetVariable("GarDur"))</send>

  </timer>
</timers>


A question though, my trigger doesn't fire if the trigger message doesn't start a new line, if it comes at the end of the prompt, due to command stacking, then it doesn't fire the trigger, how can I enable it to fire wherever the string displays?
Top

Posted by Nick Gammon   Australia  (23,133 posts)  Bio   Forum Administrator
Date Reply #8 on Tue 10 May 2011 03:15 AM (UTC)
Message
Put an asterisk at the start to match on any extra stuff, eg.


match="*You deftly slam the pommel ..."


- Nick Gammon

www.gammon.com.au, www.mushclient.com
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.


25,953 views.

It is now over 60 days since the last post. This thread is closed.     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.