Adventure Game Studio

AGS Support => Beginners' Technical Questions => Topic started by: Kinoko on Tue 17/02/2004 16:00:41

Title: Door always opens.
Post by: Kinoko on Tue 17/02/2004 16:00:41
I'm trying to get an opening/closing door thing going. I have a "door" as an object and in it's interactions, under ext. modes, I have this code:

if (UsedMode("open")) Go();
ObjectOff(0);

if (UsedMode("close")) DisplaySpeech (EGO, "It's already closed.");

Opening the door works fine, but when I click close on the door, the speech is displayed AND the Obejct is removed, hence opening the door.

Why is it adding in that extra ObjectOff action when it hasn't been specified?
Title: Re:Door always opens.
Post by: SSH on Tue 17/02/2004 16:18:24
You want:

[if (UsedMode("open")) {
Go();
ObjectOff(0);
}

if (UsedMode("close")) DisplaySpeech (EGO, "It's already closed.");



if you dont use braces around the if code, it will only treat the first statement as being conditional: the other statements will ALWAYS run...
Title: Re:Door always opens.
Post by: Kinoko on Tue 17/02/2004 16:39:42
Oh, thanks! Works like a charm now :)