Smoke Detectors
Moderators: Ice Cream Jonsey, joltcountry
- Tdarcos
- Posts: 9556
- Joined: Fri May 16, 2008 9:25 am
- Location: Arlington, Virginia
- Contact:
Smoke Detectors
I have realized I have been violating the law by having rooms with no smoke detectors. But, since it's just a game I only really need one. Is there a way I can have a room move the smoke detector to it before the room's contents are listed, or in the alternative, put a check so that if the player moves to a room with a certain attribute, to move the smoke detector there?
"When I die, I want it easy and peaceful in my sleep, like my uncle.
Not screaming and crying like his passengers."
Not screaming and crying like his passengers."
- Tdarcos
- Posts: 9556
- Joined: Fri May 16, 2008 9:25 am
- Location: Arlington, Virginia
- Contact:
Re: Smoke Detectors
Sorry, I forgot to add, I used a before routine for object MovePlayer for a room, and it didn't work.
"When I die, I want it easy and peaceful in my sleep, like my uncle.
Not screaming and crying like his passengers."
Not screaming and crying like his passengers."
- pinback
- Posts: 17926
- Joined: Sat Apr 27, 2002 3:00 pm
- Contact:
-
- Posts: 2256
- Joined: Mon Apr 29, 2002 6:23 pm
- Location: Milwaukee
Yeah, Hugo has a "found_in" property. That's one way to go.
Tdarcos, MovePlayer didn't work for you since using the before property, in that case, only works for the room you are moving *from*. In this case, you'd want to use the after property.
If every room has access to the smoke detector, you could give it the in_scope property:
That'd mean it's always within view of the player. You could also throw your attribute check in there, like:
Or to use "found_in" like pinback suggested:
Here's an example of doing an after check for MovePlayer. We'll put the code into the player object (otherwise, we'd probably want to make a class for all of the rooms with smoke detectors and throw the code in there):
Tdarcos, MovePlayer didn't work for you since using the before property, in that case, only works for the room you are moving *from*. In this case, you'd want to use the after property.
If every room has access to the smoke detector, you could give it the in_scope property:
Code: Select all
in_scope <player_object>
Code: Select all
in_scope
{
if location is smokesafe
return <player_object>
else : return 0
}
Code: Select all
found_in
{
if location is smokesafe
return location
else : return 0
}
Code: Select all
player_character you "you"
{
after
{
actor MovePlayer
{
if location is smokesafe
move smoke_detector to location
}
}
}
}
- Tdarcos
- Posts: 9556
- Joined: Fri May 16, 2008 9:25 am
- Location: Arlington, Virginia
- Contact:
Both Pinback's suggestion of found_in and your actor suggestion both work to put the smoke detector in the room, but in both cases, it's not showing up in the list of items in the room.Roody_Yogurt wrote:Yeah, Hugo has a "found_in" property. That's one way to go.
Code: Select all
player_character you "you" { after { actor MovePlayer { if location is smokesafe move smoke_detector to location } } } }
However, thanks to your explanation I figured out how to do it:
Code: Select all
player_character you "you"
{
before
{
actor MovePlayer
{
if object is smokesafe
move smoke_detector to object
return false
}
}
}
The "return false" is required or it presumes the move was not to happen. The item silently moves if necessary, and the move takes place and the item is there, and lists in the list of things in the room. Slick.
Thanks.
"When I die, I want it easy and peaceful in my sleep, like my uncle.
Not screaming and crying like his passengers."
Not screaming and crying like his passengers."
- Tdarcos
- Posts: 9556
- Joined: Fri May 16, 2008 9:25 am
- Location: Arlington, Virginia
- Contact:
Oh sorry, I forgot, obviously the smoke detector does not use "found_in" with this changed method, I set "in" to the initial room where the smoke detector is, and it works okay and is visible.
"When I die, I want it easy and peaceful in my sleep, like my uncle.
Not screaming and crying like his passengers."
Not screaming and crying like his passengers."
-
- Posts: 2256
- Joined: Mon Apr 29, 2002 6:23 pm
- Location: Milwaukee
Yeah, found_in and in_scope items are not technically in whatever room, so they are not listed (but they are accessible). I was unclear that was one of the criteria we were shooting for.
The after MovePlayer method's problem was that DescribePlace is called before the after routines are checked. If you typed >LOOK again, I'm sure it'd show up, but yeah, for your purposes, looks like you found the right solution.
The after MovePlayer method's problem was that DescribePlace is called before the after routines are checked. If you typed >LOOK again, I'm sure it'd show up, but yeah, for your purposes, looks like you found the right solution.
-
- Posts: 12
- Joined: Tue May 11, 2010 5:50 pm
- Location: Indiana
- Contact:
I thought found_in was used more like this:
note: Add this code after the player_character in the shell file to try it out. Note the use of FindObject() code in the three rooms, and calling the smoke_det's found_in.long_desc routine to print a standard description of the smoke detector.
This seems to avoid having to move the smoke detector object around.
Also note the after routine in the hall room that "removes" the smoke detector from another_room (third item listed in the found_in property.
Code: Select all
object smoke_det
{
found_in STARTLOCATION, hall, another_room ! thee holding cells for locations
long_desc {
"Small, round and slightly radioactive, the smoke detector stands a
lonely vigil against the evils of fire and smoke."
}
noun "detector"
adjectives "smoke", "small", "round", "white", "radioactive", "slightly"
}
room STARTLOCATION "Start Location"
{
long_desc {
"This is just a blah room. "
if FindObject(smoke_det, location)
call (&smoke_det.long_desc)
else
"Better not start any fires in here."
}
n_to another_room
}
room another_room "Another room"
{
long_desc {
"This is just another room, somewhat kitchenesque in looks. ";
if FindObject(smoke_det, location)
"It seems to be safe to actually cook food in here as there is a
smoke detector here."
else
"Who in their right mind would have a kitchen without a smoke detector!"
}
s_to STARTLOCATION
n_to hall
}
room hall "long hall"
{
long_desc {
"This is a rather long, lonely looking hall. ";
if FindObject(smoke_det, location)
"The smoke detector comfortably stands vigil on the ceiling of the
hall."
else
"Bad place to get caught in a fire."
}
s_to another_room
after
{
location DoGo
{
smoke_det.found_in #3 = 0
}
}
}
This seems to avoid having to move the smoke detector object around.
Also note the after routine in the hall room that "removes" the smoke detector from another_room (third item listed in the found_in property.
- Tdarcos
- Posts: 9556
- Joined: Fri May 16, 2008 9:25 am
- Location: Arlington, Virginia
- Contact:
Well, the "real" problem was that an entry for moveplayer in the player in a before or after routine is classified as "actor" not as "object". Object is used for everything else because, well, they're objects but when it was in a character, then it's an actor, which is why it wasn't working because I called it object.Roody_Yogurt wrote:The after MovePlayer method's problem was that DescribePlace is called before the after routines are checked. If you typed >LOOK again, I'm sure it'd show up, but yeah, for your purposes, looks like you found the right solution.
"When I die, I want it easy and peaceful in my sleep, like my uncle.
Not screaming and crying like his passengers."
Not screaming and crying like his passengers."
- Tdarcos
- Posts: 9556
- Joined: Fri May 16, 2008 9:25 am
- Location: Arlington, Virginia
- Contact:
For what I'm doing, moving the smoke detector is a lot simpler because, all I have to do is add the (Thanks Roody, for the name!) SmokeSafe attribute to any room that I want the detector in, and it shows up. The 4 lines in the player character to see if the room is smokesafe and to move if true, plus one attribute on any room it's to be in. Much simpler than doing lots more code in the long_desc of every room.Gerynar wrote: This seems to avoid having to move the smoke detector object around.
I kind of thought of that, initially, when Pinback suggested the found_in property, except that adding the smoke detector mention in long_desc does not look the same as when the room description routine (when entering the room for the first time or with the LOOK command).
Besides, it's just a gimmick. All the smoke detector does is if you push it (or push the test button attached to it) is say that it beeps, indicating it's working.
I happened to have the Public Service Channel on the cable on in the background while I was working on the game, and it mentioned how too many places - as many as half of all homes, despite the fact your local fire station will give you a smoke detector for free - don't have smoke detectors and a lot of people - especially children - die of smoke inhalation or are burned to death because they don't get that extra few minutes of warning telling them that there's a smoke danger.
Then I got thinking, why not put one in? Then I wanted something more elegant, instead of one detector in each room adding 30 or 40 identical smoke detectors, just have one that follows the user around to the various indoor rooms that have one. And it's nice, the rooms outside don't have it (they're not "smokesafe") and neither does the bathroom. (Exactly what's going to burn in a bathroom?)
I already did something like this in the building, it has a large air conditioner on the roof, which can only be shut off from the breaker in the <s>fuse box</s> breaker box, and then if you turn the A/C off, every room in the house without windows gives a complaint when you enter it that it's stuffy and you need to turn the A/C back on. Then once you turn it back on, it is noticably cooler.
Oh yeah, I think I'll put a fire extinguisher in the kitchen.
"When I die, I want it easy and peaceful in my sleep, like my uncle.
Not screaming and crying like his passengers."
Not screaming and crying like his passengers."
-
- Posts: 2256
- Joined: Mon Apr 29, 2002 6:23 pm
- Location: Milwaukee
You know, Paul, back when this place was fairly new, Ben was working on his own Hugo game. It also involved plumbing and fire and, more importantly, explode-y things. That game was called "Burning Down the House." You can read about it here:
http://www.joltcountry.com/phpBB2/viewtopic.php?t=16
http://www.joltcountry.com/phpBB2/viewtopic.php?t=19
http://www.joltcountry.com/phpBB2/viewtopic.php?t=31
http://www.joltcountry.com/phpBB2/viewtopic.php?t=158
Ben gave up on this dream long ago, but maybe it's time you gave it new life. Could your game have an exploding stove? A toilet bowl that you can empty? The possibilities are endless!
http://www.joltcountry.com/phpBB2/viewtopic.php?t=16
http://www.joltcountry.com/phpBB2/viewtopic.php?t=19
http://www.joltcountry.com/phpBB2/viewtopic.php?t=31
http://www.joltcountry.com/phpBB2/viewtopic.php?t=158
Ben gave up on this dream long ago, but maybe it's time you gave it new life. Could your game have an exploding stove? A toilet bowl that you can empty? The possibilities are endless!