Re: CODE RFC Room Programming Design

From: Eric Green (egreen@cypronet.com)
Date: 10/10/96


>I am creating a room programming system for AntaresMUD.

I have wrote a scripting language for my mud along this idea.  Mobs,
objects, and rooms all use the same system, eliminating the buggy and
restrictive mobprogs and allowing a consistant interface between the three
types.  The interpreter which does a lot more than mobprogs actually is
less code than mobprog.c.

>Design Requirements: Interpreted language for rooms (and later mobs and objs)
>that would be flexible, simple to learn (and debug), and as fast as possible.
>This system must allow online entry via OLC.. and dynamic program replacement,
>so a reboot will not be required. Also a means of reporting syntax errors at
>the time of entry will be included.

One requirement i put near the top of my design document was stability.  If
players are working on programs on line, they will (either intentionally or
unintensionally) put in any condition that crashes, even if (like in
mobprogs) you specifically warn "THIS WILL CRASH THE MUD."


> RETURN    - Done.. End the program. Not required at the end of the program.

One thing i found useful was being able to return a value.  This is used in
various ways depending on the trigger types.  Typically returning 0
prevents the action triggering the program to fail (such as entering a room
or droping an object).  (This idea came from Locke of The Isles.)

>  RANDOM  -- Used to create a random number between x and y

You may want to also add the ability for picking a random player in the
room, or a random object, etc.

>Temporary Variables... used for program scratchpad and text output.
>
>(Integers are initialized to 0, and strings are initialized to "NULL")
>
> Variables:
>
>    string variables. (each string may store up to 255 chars):
>    --- A$, B$, C$, D$, E$, F$, G$, H$
>
>    I% is reserved for FOR/NEXT loops.
>
>    integer variables. (Values range from -32K to 32K):
>    --- J%, K%, L%, M%, N%, O%, P%, Q%, R%, S%, T%, U%, V%, W%, X%, Y%, Z%

All of my variables are untyped, represented as strings.  All objects,
rooms, and mobs are assigned a unique integer when they are created and
then this value is added to a hash table.  To represent as a string, a
special escape character (i use '\e') is prepended to the id.  With the
hash table, lookup is realitively cheap, and guaranteed not to provide a
pointer to something not there.

Variable replacement (in most cases) is done before the line is processed.
Variables can occur just about anywhere, and are denoted by a string
surrounded by %'s.  There are local variables, visible only by that
trigger, and "global" variables shared between all triggers on something,
useful for coordinating things.

One function it looks like you are missing is the ability to pause a
program for some time.  It is nice being able to put a pulse or two delay
before reacting and between commands.  Programming this is slightly more
complicated, but is well worth the effort.

If you are interested, the user guide for my scripts is located at
http://www.cypronet.com/~dg/bresource/scripts/

If you support addition and subtraction, division and multiplication should
be only another few lines to your interpreter and should be trival to add.

There are three muds with code publicly available that i know of with
scripting systems:  Merc (mobprogs), The Isles, and Silly MUD.  I think
most if not all of these are strictly mob scripting, but some of the ideas
are useful in design of the programming language.

Porting your mud to C++ can significantly help when adding support for
scripts for multiple data types.  I kicked myself for not doing it first
after i found out how easy it was porting circle to C++.


Eric


+-----------------------------------------------------------+
| Ensure that you have read the CircleMUD Mailing List FAQ: |
|   http://cspo.queensu.ca/~fletcher/Circle/list_faq.html   |
+-----------------------------------------------------------+



This archive was generated by hypermail 2b30 : 12/18/00 PST