Community

SCI Programming => Mega Tokyo SCI Archive => Topic started by: filt on February 04, 2003, 10:09:18 AM

Title: Check if a door is locked or not.
Post by: filt on February 04, 2003, 10:09:18 AM
This may be a newbie questions. But i need some help. I want to be able to lock and unlock doors without opening them. But i cant find a way to check if the door is locked or not.

Code: [Select]
(if(send gEgo:has(INV_KEY))

This checks of i have the key.

Code: [Select]
(if( == (aDoor:doorState) DOOR_OPEN)

This checks if the door is open.

But i cant find a way to check if the door is locked...





And then i have another problem...


Code: [Select]
(instance RoomScript of Script
   (properties)
   (method (handleEvent pEvent)

If i want the
Code: [Select]
(method (doit), where should i put it?.. it seems as it doesnt work anywhere for me. I know the questions may be lame, but im new to this...
Title: Re:Check if a door is locked or not.
Post by: Eigen on February 04, 2003, 11:44:30 AM
Hope this helps. Add var DoorOpened = FALSE under Main.sc
Here's the code:

 (if(Said('unlock/door'))
           (if(send gEgo:has(INV_TEST_OBJECT))
           Print("You use your key to open the door.")
           = DoorOpened TRUE
           return
           )
           Print("You don't have a key.")
           )


          (if(Said('take/key'))
          (if(send gEgo:has(INV_TEST_OBJECT))
          Print("You alredy took it.")
          return
          )
          Print("OK")
           (if(send gEgo:get(INV_TEST_OBJECT))
           )
         )
        (if(Said('open/door'))
         (if(send gEgo:has(INV_TEST_OBJECT))
         if(DoorOpened)
         (aDoor: open)
         return
         )
         Print("It's locked.")
         return
         
         )




-Eigen
Title: Re:Check if a door is locked or not.
Post by: filt on February 10, 2003, 06:31:20 AM
I just cant get it to work. I cant find where to add "var DoorOpened = FALSE" in Main.sc
Title: Re:Check if a door is locked or not.
Post by: Eigen on February 10, 2003, 09:49:48 AM
In Main.sc don't use "var DoorOpened = FALSE" but "DoorOpened = FALSE"Add it right after:  

  gTheMusic