Scripting noob (Need help creating a script)

Posted by Klaak on Fri 08 Nov 2013 04:16 PM — 4 posts, 19,681 views.

#0
I have a character I'm playing who is certifiably insane, and I want to create a script that will choose at random from a list of commands that I select, and send that command to the mud at random time intervals between 30 seconds and 90 seconds apart.

So for instance, let's say that this character will randomly do one of the following:

giggle

whimper

cry

emote pulls frantically at her hair!

emote begins to waltz with an unseen partner.

yell 'I hate you! Go away! I'll KILL YOU!!!'
***(This one is always followed by:)***
emote begins swinging wildly at the air, as if fighting something, then suddenly stops.

Once the character does one of those things, the next time she does one could be anywhere from 30 seconds to 90 seconds after the first instance, and what she does will once again be chosen at random from the list. Then the next insane behavior will again happen at random somewhere from 30 seconds to 90 seconds after the last occurance.

Can someone please help me accomplish this? I know next to nothing about scripting.
Amended on Fri 08 Nov 2013 04:21 PM by Klaak
Australia Forum Administrator #1
Check this page out:

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


That sends a "social" randomly. You could modify it to not collect all possible socials, but just have a list of the things you want to say.

This simpler version might do it for you:


<aliases>
  <alias
   match="crazy woman"
   enabled="y"
   send_to="12"
   sequence="100"
  >
  <send>
require "wait"

wait.make (function ()  --- coroutine below here


speech = {

  "giggle",
  "whimper",
  "cry",
  "emote pulls frantically at her hair!",
  "emote begins to waltz with an unseen partner.",
  "yell 'I hate you! Go away! I'll KILL YOU!!!'",

 -- more here

  }  -- end of speech table

 
  while not GetVariable ("stop_madness") do
    wait.time (30 + math.random (60))   -- 30 to 90 seconds
    Send (speech [ math.random (1, #speech) ])
  end -- while

  DeleteVariable ("stop_madness")

  Note ("Crazy talk stopped.")
 

end)  -- end of coroutine

</send>
  </alias>

  <alias
   match="stop crazy talk"
   enabled="y"
   variable="stop_madness"
   send_to="9"
   sequence="100"
  >
  <send>stop</send>
  </alias>


</aliases>


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


That makes an alias with a list of things to say (see "speech" table above).

Start it by typing:


crazy woman


It picks one from the list every 30 to 90 seconds. It loops doing that, so to stop it type:


stop crazy talk
#2
Thanks Nick! Works great. I added another 80 socials out of the 200+ on the mud, and changed the alias to match on "insane" instead of "crazy woman" and "sane" instead of "stop crazy talk". Those are much quicker to type so I can shut them off when I enter combat.

The only problem with it all, is that the note about "Crazy Talk Stopped" outputs when I use the alias to START the crazy talk, instead of when I STOP it. I tried just moving the note to the second alias, but now the note doesn't show up at all. How do I make that note appear when I turn it off, instead of when I turn it on?
Australia Forum Administrator #3
If that variable ("stop_madness") already existed that might happen. Try again, it should be OK the second time.