MUSHclient simple alias script
Updated 12th June 1997.
In a lot of worlds, you teleport yourself around to key locations, but remembering
those room numbers is somewhat of a pest. This script that I present here shows
how you can translate easy-to-remember room names into a room number to teleport
Let us say, for example, that you have a room called "oasis" that you
teleport to a lot. Its room number is 19, so using normal MUSH commands you would
have to type:
However, by using the alias and script presented below, you can now type:
Setting up the script subroutine
I'll assume that you have installed VBscript by this time. If so, you should be able
to type the command:
/world.note "Hi there"
and see "Hi there" appear in your output window. If not, see the
page: scripting setup for more details.
Next, use Notepad (or some other text editor) to edit the script file (the file
whose name appears on the "scripts" configuration page) and add the
sub OnTeleport (thename, theoutput, thewildcards)
sDestination = Trim (thewildcards (1))
' if nothing entered echo possible destinations
if sDestination = "" then
world.note "-------- TELEPORT destinations ----------"
world.note "BAZAAR, OASIS, PUB, HOME, SQUARE, CAVE"
' they entered a destination - test against possibilities
select case uCase (sDestination)
iRoom = 34
iRoom = 19
iRoom = 246
iRoom = 1002
iRoom = 8342
iRoom = 2253
world.note "******** Destination " & sDestination & " unknown *********"
world.note "------> Teleporting to " & sDestination
world.send "@teleport #" & cstr (iRoom)
What is happening above is:
- The script declares two "variables" (things which can hold numbers
or strings or other things), named "sDestination" and "iRoom".
- The third parameter passed into the script subroutine (called "thewildcards"
here, but you could call it anything) is the list of wildcards to the alias,
in other words "whatever the user typed after the word TELEPORT".
- This first wildcard ("thewildcards (1)") is "trimmed" by
using the "Trim" function. This removes leading and trailing spaces,
and moved into the variable "sDestination" in the process.
- If the destination is blank (ie. the user typed nothing in) then the program
echoes the possible teleport locations, and exits the subroutine.
- Otherwise, using the "select case" statement the variable "sDestination"
(forced to upper-case by the "uCase" function) is tested against
all the possible destinations, and if it matches, the appropriate room number
is moved into "iRoom".
- If there is no match, a warning message is displayed (using world.note) and
the subroutine exits.
- If there is a match, the subroutine displays an informative message,
and then sends the appropriate teleport command to the world.
Linking the alias to the script
The only thing that remains is to add an alias called "teleport" (you could
make it "tel" if you want to save some typing), and tell it to call
the script subroutine "OnTeleport" (ie. the one you just created) if
someone types "teleport".
The resulting alias will look like this:
- The "alias" field is what is matched on to trigger the alias. You
can make it "tel" if you like, or "TEL", remembering that
aliases are case-sensitive.
- It is important to type the alias exactly as:
so MUSHclient knows to send the rest of what you type after the word "teleport"
to the script subroutine.
- Leave the "send" area empty - you want the script to send things
to the world, not the alias directly.
- Aliases that call scripts must have a label, it doesn't matter what it is,
as long as it is unique.
- In the "script" box type the name of the subroutine that was keyed
into the VBscript file.
- You can see from the example above that MUSHclient maintains a count of how
many times a script was called. You can see that I tested the above script
8 times in the course of writing this article.
Test it out!
Having typed in the script, and set up the alias, you are ready to try it! Here is
what it looked like for me...
If you get syntax errors, just edit the script file and correct them. If you
are using Window NT, MUSHclient will automatically detect that you have changed
the script file and offer to reprocess it. If you are using Windows 95, just
use the "reload script file" function (Shift+Ctrl+R).
Change to suit your requirements
Of course, you would want to change the script to reflect both the room names and
numbers that pertain to your own worlds. Hopefully this example will inspire
you to start creating your own scripts. If you make an interesting one, please
email it to me (address below) so I can add it to the example scripting pages.
More complex example...
The major problem with this script from a MUSHing point of view, is that you have
to recompile it every time you want to add a new room to the list. Click here
for scripting a complex alias.
Comments to Gammon Software support
Page updated on Tuesday, 6 December 2005