| Message |
OK, first let's look at the difference between manually entering a timer or trigger, and doing it in a script.
By "manually" doing it, you simply use the MUSHclient configuration screen to type in a trigger, timer, alias or whatever. This is fine if you can plan to do something in advance, like set up a timer that says "inventory" every hour to stop your being disconnected for inactivity.
However you might want to have a script add a timer, for example if you want to do something 2 seconds after a trigger fires.
Addtimer (in a script) looks like this:
World.addtimer "my_timer", 1, 10, 30, "parry high", 5, "my_timer_script"
(This is in VBscript). Breaking it up piece-by-piece ...
"my_timer" - the name of the timer (used if you need to delete or reset it)
1 - the number of hours to wait, plus
10 - the number of minutes to wait, plus
30 - the number of seconds to wait
"parry high" - what to send to the MUD
5 - some flags - in this case enabled=1 plus one-shot=4. So, adding the flags together gives 5.
"my_timer_script" - the name of the script to execute when the timer fires (optional)
The various flags are documented on the page http://www.gammon.com.au/mushclient/functions.htm.
For example, if you add 2 to the flags it becomes a timer that fires at a particular time (in this case 01:10:30).
Now, to solve your problem, basically you want to set up a script that, when you are attacked, sends "parry high" 1.5 seconds later.
The first point is that I haven't allowed for sub-second timers. In my view, because of lag and other considerations, rounding to the nearest second should be good enough. So, let's make it 2 seconds.
You need, then, a trigger that matches on the event that needs the parry. You haven't said what that is, but let's assume it is something like:
The Gorgon attacks you!
Thus, you set up a trigger like this:
Trigger: * attacks you!
Label: attack_trigger
Script: OnAttack
Then you need a script routine (OnAttack) that sets up the timer to fire 2 seconds later and do the parry. Thus you add to the script file:
sub OnAttack (TriggerName, TriggerLine, Wildcards)
World.addtimer "my_timer", 0, 0, 2, "parry high", 5, ""
end sub
This trigger adds a one-shot timer that fires in 2 seconds. When it fires it sends "parry high" and then deletes itself.
This is simple enough. You can modify this general idea for all sorts of things.
|
- Nick Gammon
www.gammon.com.au, www.mushclient.com | top |
|