Register forum user name Search FAQ

Gammon Forum

Notice: Any messages purporting to come from this site telling you that your password has expired, or that you need to verify your details, confirm your email, resolve issues, making threats, or asking for money, are spam. We do not email users with any such messages. If you have lost your password you can obtain a new one by using the password reset link.

Due to spam on this forum, all posts now need moderator approval.

 Entire forum ➜ MUSHclient ➜ General ➜ a scripting question

a scripting question

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


Posted by Forrest Hudspeth   (2 posts)  Bio
Date Fri 18 Jul 2003 01:24 AM (UTC)
Message
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
Top

Posted by Nick Gammon   Australia  (23,173 posts)  Bio   Forum Administrator
Date Reply #1 on Fri 18 Jul 2003 06:14 AM (UTC)
Message
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).

- Nick Gammon

www.gammon.com.au, www.mushclient.com
Top

Posted by Forrest Hudspeth   (2 posts)  Bio
Date Reply #2 on Fri 18 Jul 2003 07:30 PM (UTC)
Message
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

Top

Posted by Nick Gammon   Australia  (23,173 posts)  Bio   Forum Administrator
Date Reply #3 on Fri 18 Jul 2003 09:53 PM (UTC)
Message
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





- Nick Gammon

www.gammon.com.au, www.mushclient.com
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.


16,453 views.

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

Go to topic:           Search the forum


[Go to top] top

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