Axe Software Forums
  Quest Developer Forum
  problem with vars & conditionals


Author Topic:   problem with vars & conditionals
mortimer jazz posted 20-02-2003 13:10 GMT     
Hello. I'm having a few initial problems getting a proceedure to execute (btw, at the moment I'm not writing code by hand).
In room1 (player enters room scriptbox) I set the following line of code:
script set string <canStatus; full>
In room2 (player enters room scriptbox) I set this conditional:
script {
msg <test>
if ( canStatus = full ) then msg <test2> else msg <error>
}
I keep getting an error. Does the program remember that canStatus is a string? I'd be grateful if someone could point out where I'm going wrong. :)
Cheers,
Mort.
MaDbRiT posted 20-02-2003 19:28 GMT          
Hi Mort.

Are you missing the " # " characters in your test? If so try with this:-

quote:

if (#canstatus# = full) then msg <OK> else msg <not OK>

Al


mortimer jazz posted 23-02-2003 18:11 GMT          
Ah :)
Very much appreciated. Thanks Al
___________________________________
A related question if I may .... I've given an object a property using the 'edit object' button (edit object >interactions > p&a >properties).
My TV has the property "isOn" with an initial value of "false". How can I check or change this? I can't get it to work in the same way as vars. When the player examines the TV I want to run different scripts (and switch the property value)depending on the stutus of this property. I can't see how to do this in the help section.
Thanks again
Mort
MaDbRiT posted 24-02-2003 07:57 GMT          
mortimer jazz wrote:

quote:

My TV has the property "isOn" with an initial value of "false". How can I check or change this? I can't get it to work in the same way as vars. When the player examines the TV I want to run different scripts (and switch the property value)depending on the stutus of this property. I can't see how to do this in the help section.

By supplying a value of the typed word 'false' - which I assume is what you mean by the above, you are actually creating a string property and storing the word "false" in it, not creating a Boolean property that is either true or false - which I think is what you actually want to do here (The TV is either on or off - no other possibilities).

To create a property of this type, you do NOT supply a value argument. The logic is that the object then either has the property 'IsOn' - or it doesn't.

You'd check this with something like:

quote:

if property <TV;IsOn> then {
msg <The TV is showing a naff game show.>
}
else msg <The TV is off.>

You could test for it NOT having IsOn like so:

quote:

if not property <TV;IsOn> then {
msg <The TV is off.>
}
else msg <The TV is showing a Baseball match.>

So either way is possible.

You change the TV's 'IsON' status with a properties statement like so.

quote:

properties <TV; Ison> 'makes IsOn = true
or
properties <TV; not IsOn> 'makes IsOn = false

Hope this helps!

This is the sort of thing I hope to explain in my forthcoming Quest ASL tutorial, although it will concentrate on coding by hand rather than through QDK, the logic of this kind of thing is exactly the same whichever way you create it.

Al