I'm confused about object properties.

Robert
04 Jul 2003, 08:59
Hello everyone,

I'm confused about object properties.

What I'd like is to have is a grate that is initially closed. You pick up a sword, and use it on the grate. This opens the grate. If you look at the grate before or after you use the sword on it, it tells you whether it's open or closed.

My ASL code is below:

define room <Courtyard>

define object <Grate>
look if property <Grate; prOpen=true> then msg <The grate is open.> else msg <The grate is closed.>
properties <prOpen=false>
end define

define object <Sword>
take
use on <Grate> {
property <Grate; prOpen=true>
create exit north <Courtyard; Tunnel>
}
end define

end define

Can anyone spot what I'm doing wrong please?

Thanks for any assistance.

Best regards from Robert.

Alex
04 Jul 2003, 09:16
"if property" checks whether a property exists, and the format is "if property <object name; property name>", not "if property <object name; property name = value>". Properties without values are either on or off; properties with values can be anything.

So, there are two ways of fixing your problem:

1. Use boolean properties, which are either on or off. So, instead of using "properties <prOpen = false>", use "properties <not prOpen>". Then instead of "property <Grate; prOpen = true>", use "property <Grate; prOpen>". Instead of "if property <Grate; prOpen = true>", use "if property <Grate; prOpen>".

2. OR use the correct syntax for checking whether an object's property has a particular value. This isn't done using "if property", as that only checks boolean (on/off) properties, and here you're setting properties to values of "true" or "false". A subtle difference, and one that has been misunderstood in the past - so I will probably add value-checking support for "if property" to future versions of Quest. Until then, the proper syntax to use is "if ( #Grate:prOpen# = true) then ..." (and this is the best syntax to use even if I do implement "if property <object name; property = value>", as you can also use checks other than "=" with this syntax, such as greater than >, less than < etc.)

Hopefully this makes sense, I seem to have waffled a bit.

Robert
04 Jul 2003, 10:48
Thanks a lot for your help Alex; that's fixed my problem.
- Robert.

Hemo
17 Jul 2003, 12:15
:) Not to worry Alex. Waffling is a great source of good ideas.