Geas MUD, enter the Aventure!
Geas Home | Play the Game

[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

2.1 Peeking at things to come

In order to provide you with examples of what I'm trying to teach you, I need to explain a few functions in advance. They will be repeated in their correct context later, but here's a preview so that you'll know what I'm doing.

To present things on the screen for the player to read, you use the efun write(). There's two special characters that's often used to format the text, `tab' and `newline'. They are written as \t and \n respectively. The `tab' character inserts 8 space characters and `newline' breaks the line.

void write(string text)
    write("Hello there!\n");
    write("\tThis is an indented string.\n");
    write("This is a string\non several lines\n\tpartly\nindented.\n");

    /* The result is:

       Hello there!

               This is an indented string.

       This is a string
       on several lines

If you have an array, mapping, or simply a variable of any kind that you want displayed on the screen for debugging purposes the sfun dump_array() is very handy. You simply give the variable you want displayed as an argument and the contents (any kind) will be displayed for you.

void dump_array(mixed data)
    string *name = ({ "fatty", "fido", "relic" });

    /* The result is

       [0] = (string) "fatty"
       [1] = (string) "fido"
       [2] = (string) "relic"

This document was generated by Ronny Wikh on July, 8 2003 using texi2html