Author Topic: Check if a door is locked or not.  (Read 2816 times)

0 Members and 1 Guest are viewing this topic.

Offline filt

Check if a door is locked or not.
« 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...



Offline Eigen

Re:Check if a door is locked or not.
« Reply #1 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
Artificial Intelligence Competition

Offline filt

Re:Check if a door is locked or not.
« Reply #2 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

Offline Eigen

Re:Check if a door is locked or not.
« Reply #3 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
« Last Edit: February 10, 2003, 09:53:08 AM by Eigen »
Artificial Intelligence Competition


SMF 2.0.19 | SMF © 2021, Simple Machines
Simple Audio Video Embedder

Page created in 0.046 seconds with 20 queries.