Does anyone have an idea of how I might go about setting up the ability to look in a given direction? For example, if the player were to type "LOOK NORTH", they could be given a description of that. My guess is I would want some property that just displayed a string, like:
north_look = "You see stuff that is to the north."
But I am not certain yet how to go about actually implementing that. I will go through the library files as well and see if I can ferret out an answer for myself but I figured I would try to cover all my bases just in case this is a problem someone ran into before.
Looking in a Direction
Moderators: Ice Cream Jonsey, joltcountry
-
- Posts: 55
- Joined: Wed May 05, 2004 4:35 am
- Location: Chicago, IL
- Contact:
-
- Posts: 119
- Joined: Fri Jun 27, 2003 12:10 pm
Right now >LOOK WEST will get you something like "You see nothing special to the west", which is generated in objlib.h by the direction class's long_desc property.
You could either handle this specially in a given location's before property as in:
or, if you wanted to do this throughout the game, you could derive a class from the basic room class and use that to build all your locations. Your derived class could have special handling to do more or less the above for any existing west_desc, etc. properties for the location. Something like:
(Please note that all this code is untested.)
Note that if, for instance, self.north_desc doesn't exist on the location object, it's the same as returning false in the above code. Your north_desc property, then, would look like:
Hopefully that's sort of clear, or at least a start.
You could either handle this specially in a given location's before property as in:
Code: Select all
before
{
location DoLook
{
if object = w_obj
"...Your description here..."
else
return false
}
}
Code: Select all
room myroom
{
before
{
location DoLook
{
if object = n_obj
return self.north_desc
if object = ne_obj
return self.northeast_desc
...
else
return false
}
}
}
Note that if, for instance, self.north_desc doesn't exist on the location object, it's the same as returning false in the above code. Your north_desc property, then, would look like:
Code: Select all
north_desc
"You see stuff that is to the north."