New to Scripting - Random Timer Needed Please

Posted by Mikeof85 on Thu 27 Nov 2014 01:57 AM — 5 posts, 26,140 views.

#0
Hello. I'm COMPLETELY NEW to scripting. I have zero experience. I'm usually good at researching for the answers I need, but I just cannot seem to find anything that works. Could someone please help?

Okay here's an example of what I need:

I cast a spell and the world returns with "You cast hurricane."



What I would like is to have a random timer between that notice and me automatically casting again with "Cast hurricane"



**World** "You successfully cast hurricane."
--Random amount of time elapses between 2 and 20 seconds--
**Me** "Cast Hurricane"



I want it to be a one-shot timer, this way I can switch to another task if I need to.



I'm open to LUA or Jscript, but I'll need helping learning how to do either, and setting mushclient up to execute the script.
#1
Here's what I have so far. In all likelihood I could be waaaaay off base. The musclient is saying i have an error on line 2... No clue what to do. Thanks for any help!


function randtimer ( ) {
var randomtimer = (Math.random()*20)+2);
World.DoAfter(randomtimer,"cast hurricane");
}
Australia Forum Administrator #2
If you are really new to scripting I suggest you use Lua rather than Jscript. Then it is easy:


<triggers>
  <trigger
   custom_colour="2"
   enabled="y"
   match="You cast hurricane."
   send_to="12"
   sequence="100"
  >
  <send>
DoAfter(math.random (2, 20), "cast hurricane")
</send>
  </trigger>
</triggers>


Template:pasting
For advice on how to copy the above, and paste it into MUSHclient, please see Pasting XML.
USA Global Moderator #3
This particular task is just as easy in Javascript as in Lua. You just have mismatched parentheses on your second line. (2 open, 3 close)
Amended on Thu 27 Nov 2014 07:26 PM by Fiendish
Australia Forum Administrator #4
Quote:

The musclient is saying i have an error on line 2.


It might have been easier to help if the original question included the error message.