[Home] [Downloads] [Search] [Help/forum]

Gammon Forum

See www.mushclient.com/spam for dealing with forum spam. Please read the MUSHclient FAQ!

[Folder]  Entire forum
-> [Folder]  MUSHclient
. -> [Folder]  Jscript
. . -> [Subject]  New to Scripting - Random Timer Needed Please
Home  |  Users  |  Search  |  FAQ
Username:
Register forum user name
Password:
Forgotten password?

New to Scripting - Random Timer Needed Please

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


Posted by Mikeof85   (2 posts)  [Biography] bio
Date Thu 27 Nov 2014 01:57 AM (UTC)
Message
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.
[Go to top] top

Posted by Mikeof85   (2 posts)  [Biography] bio
Date Reply #1 on Thu 27 Nov 2014 02:05 AM (UTC)
Message
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");
}
[Go to top] top

Posted by Nick Gammon   Australia  (21,321 posts)  [Biography] bio   Forum Administrator
Date Reply #2 on Thu 27 Nov 2014 05:10 AM (UTC)
Message
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.

- Nick Gammon

www.gammon.com.au, www.mushclient.com
[Go to top] top

Posted by Fiendish   USA  (1,641 posts)  [Biography] bio   Global Moderator
Date Reply #3 on Thu 27 Nov 2014 07:25 PM (UTC)

Amended on Thu 27 Nov 2014 07:26 PM (UTC) by Fiendish

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

https://github.com/fiendish/aardwolfclientpackage
[Go to top] top

Posted by Nick Gammon   Australia  (21,321 posts)  [Biography] bio   Forum Administrator
Date Reply #4 on Thu 27 Nov 2014 08:03 PM (UTC)
Message
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.

- Nick Gammon

www.gammon.com.au, www.mushclient.com
[Go to top] 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.


3,379 views.

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

Go to topic:           Search the forum


[Go to top] top

Quick links: MUSHclient. MUSHclient help. Forum shortcuts. Posting templates. Lua modules. Lua documentation.

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

[Home]


Written by Nick Gammon - 5K   profile for Nick Gammon on Stack Exchange, a network of free, community-driven Q&A sites   Marriage equality

Comments to: Gammon Software support
[RH click to get RSS URL] Forum RSS feed ( https://gammon.com.au/rss/forum.xml )

[Best viewed with any browser - 2K]    [Hosted at FutureQuest]