Register to post in forums, or Log in to your existing account
 

 Related 
Contents
Getting Started
  Playing a MUD game
  Quick Start
  User Interface
  Basic Usage
  Terminology
  Scripting
    Introduction to Aliases
    Introduction to Macros
    Introduction to Variables
    Introduction to Classes
    Introduction to Triggers
    Introduction to Buttons
    Introduction to Multiplaying
    Introduction to Paths
    Introduction to Events
Related Links:
  Editing Events
  Feature Summary
  Editing Aliases
  Editing Macros
  Editing Triggers
  Editing Buttons
  Editing Menus
  Editing Functions
Scripting [[cmud_scripting]] 
While the CMUD User Interface is nice, most MUD players are drawn to CMUD because of it's powerful scripting system. By creating scripts you can automate many normal MUD tasks, allowing your MUD character to respond more quickly to dangerous situations, or to simply make the MUD easier to play. Advanced CMUD users can even write scripts to completely automate their character (on MUDs that allow this).

Each MUD has it's own rules about what kind of scripting is allowed. Be sure to always check your MUD rules to make sure scripting does not violate them. If you violate your MUD rules, your character can get deleted, and you might be banned from playing that MUD in the future.

Most MUDs allow simple scripting. That is: aliases, macros, simple triggers, etc. As long as you are in front of your computer and actively playing your character, then you are usually safe. However, if you start creating "bots" that automatically control your character when you are not in front of the computer then you should always check the MUD rules. Most MUDs do not allow this kind of unattended "bot" scripting. Just because CMUD allows you to do it doesn't mean that it's allowed on the particular MUD you are playing.

Scripting Basics

Writing a script is similar to writing a computer program. CMUD tries to make this easier than most programming languages and is specifically designed for common MUD tasks.

The most important part of scripting to remember is that you are writing instructions for CMUD to carry out some sort of task. These instructions need to be written in a way that CMUD can understand them. Try to be careful to learn the correct "syntax" for scripts. Most scripting errors are caused by being sloppy and forgetting a punctuation character.

You can create scripts in two different ways: (1) via the Package Editor, and (2) via the command line. The Package Editor is a visual editor that allows you to create and edit your scripts. It provides some color syntax highlighting and syntax checking. Novice users should start with the Package Editor.

Because scripts can also be entered directly into the command line, CMUD needs some way to distinguish script text from normal MUD text. CMUD does this by using some special punctuation characters:
#
This is the "command character". It is always used to indicate the name of a CMUD Command that you want to execute. For example, to use the #ECHO command to display a message on the screen, you would type something like this:

#ECHO Hello World

%
This is the "function character". Sometimes called the "parameter character". It is used to indicate the name of a CMUD Function that you want to execute. For example, to display a random number from 0 to 100, you can type this:

#ECHO %random

This calls the #ECHO command to display a message, but instead of a message we call the %random function to return a random number.
;
This is the "separator character". It is used to separate multiple commands on a single command line. For example, if you wanted to send two commands to the MUD: "open door" followed by "enter", then you could type this:

open door;enter

It's important to never put any spaces around the ; character. Also, putting some punctuation after the ; might cause CMUD to think you are sending a "smiley" to the MUD such as ;).
@
This is the "variable character". It is used to retrieve the value of a Variable that you have defined. A Variable is a container for a value, just like variables in other programming languages. It's important to remember that you only use the @ character when you are trying to retrieve the value stored in the variable. For example, @A will retrieve the value stored in the "A" variable.

 User comments 
Fang Xianfu: Fri Aug 10, 2007 3:24 pm    

This section is missing an "Introduction to Events" article.
Viewer Comments [1 - Post your comments]

Jump to:  

© 2009 Zugg Software. Hosted by Wolfpaw.net