Place-Based Room Descs
Overview
The venerable places code is an incredibly useful staple of MUSH building. Over the years, it's been used in all sorts of creative ways. This code provides a way to change the desc (and faedesc, umbradesc, wraithdesc, etc) based on where in the room a character is. It can even be used to simulate entire rooms.
A Little of the Nuts and Bolts
The core of the system is the following function, which should be set on either the room in question, or on a parent object for all of the rooms in the build:
- &f.position [here (for room) or dbref (for parent)]=[setq(0,0)][iter(v(placenums),[if(gt(match(##,%#),0),setq(0,#@),)],|)]
This simply identifies if an observer is at one of the places in the room, and if so, which. It then records that information in Register 0 (ie: r(0) or %q0 ).
The roomdesc itself (@desc here) is set as follows:
- @desc here=[u(f.position)]%r[if(hasattr(me,d.placedesc[r(0)]),get_eval(me/d.placedesc[r(0)]),get_eval(me/d.placedesc0))]
This calls the function to initialize r(0), then checks to see if the place desc required exists. If it does, it uses it. If it doesn't, it uses the default description. This allows some places to have their own descriptions, such as a separate room, or a high balcony that drastically changes the observer's vantage point, while others like a bar or table, might not.
From there, the 'default' description of the room is set in:
- &d.placedesc0 here=[default desc if you're not at a place]
The naming conventions on these are fairly simple. D.* for data, F.* for functions. Any commands (there are none for this code at the moment) would be stored as C.* attributes.
That's the basic elements. This can also be used to apply to faedescs, wraithdescs, umbraldescs, etc, by using some variation of what follows (this is written for fae descs because my character right now is a fae):
- &faedesc here=[if(hasattr(me,d.fplacedesc[r(0)]),get_eval(me/d.fplacedesc[r(0)]),get_eval(me/d.fplacedesc0))]
This does exactly the same thing as the @desc code, but because r(0) has been initialized, it doesn't need to redo that step. Then, the default and place descs follow similar naming configuration as the regular desc elements. The name is only slightly changed (the 'f' to represent 'fae', would change to 'u' for umbral, or 'w' for wraith) to match which layer of reality is being impacted.
Example:
- &d.fplacedesc0 here=[default faedesc]
- &d.fplacedesc1 here=[faedesc to display when sitting at place1]
One-Stop Drop-In
Remember, if this is being placed on a parent object, replace 'here' with the DBREF of the parent.
- &f.position here=[setq(0,0)][iter(v(placenums),[if(gt(match(##,%#),0),setq(0,#@),)],|)]
- @desc here=[u(f.position)]%r[if(hasattr(me,d.placedesc[r(0)]),get_eval(me/d.placedesc[r(0)]),get_eval(me/d.placedesc0))]%r
Then set descs in:
- &d.placedesc[#] here=[Description]
Where # is the number of the place, and 0 for the default description. Remember, these need to be on the room, NOT the parent object.
Please note that this is not currently integrated with any other variable description systems, such as a day/time/season variable description (like the time/day elements at Atlantis).
Assistance
If you have any questions or run into any trouble with the code, please feel free to poke Kieran (Kee) in-game. I'll update this if there are improvements, or if I make an alt who can see the other layers, to include more examples and options.