a scripting question

Posted by Forrest Hudspeth on Fri 18 Jul 2003 01:24 AM — 4 posts, 17,351 views.

#0
hi,

I want to make an alias for a pretty simple task, but I have no idea how to do it. I'm pretty sure that it will require the use of scripting though. I have a bunch of aliases, and I want another alias to call one of these other aliases at random. How can I do this?

Thanks a lot :D
Australia Forum Administrator #1
You can get an alias to call another by sending to "execute".

There is an example of doing things at random in the "random socials" plugin, which might give you some ideas.

However a simple approach might be to simply have one alias that just gets a random number (using rnd) and then uses that in a select case statement to execute one of a batch of other aliases (yes, this would require scripting).
#2
hmmmmmm, thanks for the help

however I still have one thing that I need to know. I've looked in the help files, but I think that they're out of date or something...

how do I call an alias from a script?

I've got some pseudo-code for what I think it will need to do, but I don't know any of the scripting languages well enough to get it into real code.

--------------------
random_variable = (number 1-4)

if random_variable = 1
call alias 1
else if random_variable = 2
call alias 2
else if random_variable = 3
call alias 3
else if random_variable = 4
call alias 4
end if
--------------------

if someone could translate that into one of the scripting languages the MUSHclient supports I would be eternaly thankful

Australia Forum Administrator #3
There is a more up-to-date help file, see:


http://www.gammon.com.au/forum/bbshowpost.php?bbsubject_id=2732


As for executing an alias, see the new help file, which is also available online, see:


http://mushclient.com/scripts/doc.php?function=Execute


In your case you would:


if random_variable = 1 then
  world.Execute "alias 1"
else if random_variable = 2 then
  world.Execute "alias 2"
else if random_variable = 3 then
  world.Execute "alias 3"
else if random_variable = 4 then
  world.Execute "alias 4"
end if