Programming Tips


Here is a list of all the fabulous programming tips discovered throughout the ages. If you can't find a solution to your problem here, ask a professor, and be sure to submit it for publishing here!

Contents

Using $g
Be careful when using @recycle!
Back up before using chparent.


Don't use hard-coded object numbers in your code. If you need to refer to a static object, use a $g property.

To search $g for a property, use the command:

dollarg substring

For example, at the prompt:

    >dollarg lan
    Candidates on $g:
    1.  $g.lantern_room #956
    2.  $g.lantern #973
    => 0
Note: a substring argument, like "lan" for lantern returns every label containing that substring


If you wish to add a property to $g, use the add_dollarg_prop verb

The format of this verb is:

;$g:add_dollarg_prop("member_function_room", #1717)

This particular example will bind $g.member_function_room to the value #1717.

For more information on $g properties and their importance in Geology Explorer read the article The Importance of $g by Dr. Brian Slator


Checking if an object already has a $g property

The other direction is also possible. If you want to check to see if an object has an entry in $g, simply run the following evaluation:

;for n in (properties($g)) if ($g.(n) == object_number) player:tell(n); endif endfor

Simply relace object_number with any particular object number (For example: #956 which will return lantern_room)


Be careful when using @recycle!

@recycle is irreversible. Be very careful when using it. (Ok, it's not irreversible, you can retrieve the object from backup, but be very careful nonetheless. It's a pain recovering from backup)


Back up before using @chparent

@chparent removes properties and verbs depending on how it's used. Make sure you backup the object before using it. That way, if you need to, you can @chparent it back and put it back to the state it was. Do this by running the command @dump object_number. Then you just have to copy and paste the code it sends out back into tkMOO (or your favorite text-based MOO connection program)



Return to the GEPM Table of Contents