Problem with Visited attribute
Posted: Mon Sep 10, 2012 1:17 pm
I have a refrigerator in the kitchen. I want to show a message the first time the user issues the command "open refrigerator" (or "open fridge" or "open icebox"), and a different item thereafter, so in either the before event or the after event of the refrigerator object I have the following:
If placed in the "before" event, this works to show the phrases correctly, but for some reason the door isn't locked. If placed in the "after" event, it apparently sets "visited" before this is even called so the first message never gets seen. (I discovered I have to set the visited attribute when its in the before event or that attribute doesn't get set.) Maybe I need to return false instead of true, I never did understand which return means which.
I looked through the DoOpen routine and I can't see where the visited attribute is set before the "after" code is called, and i don't see why I can't set the locked attribute in the "before" event.
Code: Select all
object DoOpen
{
if (self is not visited)
{
print "The refrigerator apparently hasn't been cleaned since Enron
was in business. A number of items inside look like they're some sort
of science experiment. The green cottage cheese apparently has
become sentient, as it says to you, \"Hey, close the door, you're
letting all the cold out!\" You hastily close the door."
self is not open
self is visited
return true
} else {
print "The green cottage cheese looks at you again, and says
\"Don't you listen? I told you to close the door, you're letting all
the cold out! Leave it closed, there's nothing you want in
here.\" Something else grabs the door and closes it, doing
something that sounds suspiciously like a bolt being thrown."
self is not open
self is locked
return true
}
}
I looked through the DoOpen routine and I can't see where the visited attribute is set before the "after" code is called, and i don't see why I can't set the locked attribute in the "before" event.