Alias generates random emote from array

Posted by Janus on Tue 10 Feb 2009 10:32 AM — 4 posts, 17,401 views.

#0
Hello,

I play a MUD called armageddon. Normally when I climb I type code like U (emote) eg: U (gripping the rope tightly) productes output : Gripping the rope tightly, you climp upwards.

Id like to create an alias that will randomly fire say 20% of the time, and when it fires, appends a random emote from an array of emotes.

dim climb
climb[1]="spitting into ^me hands and rubbing them together"
climb[2]="taking the strain on the rope"
..
climb[18]="gripping the rope tightly"
climb[19]="wrapping the wrope around ^me leg"
climb[20]="blinking as dust falls in ^me face"

I've had a look through the forums, but can't get this working myself. If anyone could offer a suggestion, or point to a relevant thread, i'd be most grateful.

Thanks
#1
Hello,
I found a very useful article on a teleport alias which looks really promising for a starting place.

Only problem is, I've copied and pasted it correctly, but I think the alias is wrong? Ive got:

add_teleport * *

as per the example, but if i type this:

add_teleport desert 4343

the script is throwing back:

Syntax: add_teleport name dbref
eg. add_teleport LandingBay 4421

as if the variables are not being passed across.

Am I being really dumb?
Australia Forum Administrator #2
For the random emotes, there is a plugin on this page:

http://www.gammon.com.au/mushclient/plugins/

It is called Random_Socials and it does that general idea. However it builds up its list from what the MUD offers as socials.

It is pretty simple to do the random stuff in Lua, so I'll illustrate it here:


<aliases>
  <alias
   match="U"
   enabled="y"
   send_to="12"
   sequence="100"
  >
  <send>

do -- keep emotes table local

  local emotes = {
     "spitting into ^me hands and rubbing them together",
     "taking the strain on the rope",
     
  -- add more anywhere

     "gripping the rope tightly",
     "wrapping the wrope around ^me leg",
     "blinking as dust falls in ^me face",

   } -- end of emotes table

  if math.random (0, 100) &lt;= 20 then   -- 20% of the time
    Send ("U (" .. emotes [math.random (1, #emotes)] .. ")")
  else
    Send ("U")
  end -- if

end -- do  

</send>
  </alias>
</aliases>


This maintains a local table of possible emotes, which it randomly chooses one from, 20% of the time. Just add more into the table in the same format, and it will adjust to the new size (it picks one from the first to #emotes, which is the size of the table).

See: http://mushclient.com/pasting for how to paste that into the client.
#3
Thats exactly what i was after.

Thank you so much, I would never have figured that out on my own.