Author Topic: SCI0: doors  (Read 1650 times)

0 Members and 1 Guest are viewing this topic.

Offline robbo007

SCI0: doors
« on: April 20, 2023, 06:40:18 AM »
Hi guys,

Having some issues with my doors. I'm using the control colours to control it and the templates door script. What's happening is when you type "open door" and your not on the navy control colour it says "Not close enough", which is correct. But if you type "open door" again it says "It is" which is not correct.

What I think is happening is its running the (aDoor open:) which is the template door script then checking ego is not on the navy control, then its setting my variable to "open" as its defined straight after the (aDoor open:). Is there a way to set only the  "open" variable if the (aDoor open:) has finished opening the door ?

Code: [Select]

(local
bardoor = "closed"
)

(aDoor init:)

(if(Said 'open/door')
(if (== bardoor "closed")
(aDoor open:)
(= bardoor "open")
else
    (PrintItIs)
    )
)
    (if(Said 'close/door')
    (if (== bardoor "open")
    (aDoor close:)
    (= bardoor "closed")
    else
    (PrintItIs)
    )
)

(instance aDoor of Door
(properties
view vRoom
loop lDoor
x 183
y 93
doorCtrl ctlNAVY
roomCtrl                 ctlGREEN
doorBlock         ctlYELLOW
entranceTo 106
cycleSpeed 4
)

(method (init)
(super init:)
(self
;setCycle: Beg
setPri: 6
)
)
)





Offline Kawa

Re: SCI0: doors
« Reply #1 on: April 20, 2023, 07:53:07 AM »
Instead of using a separate variable that holds a string value, I highly suggest you use the door's own doorState property, which can be DOOR_OPEN. Most of the "not close enough" stuff is actually already built into the door class.

Offline robbo007

Re: SCI0: doors
« Reply #2 on: April 20, 2023, 08:17:41 AM »
I did see those states but was not sure of the right syntax to get it working. I did try this but not luck, Just says "It is" if you type "open door". I gather I'm missing something with the syntax ?

Code: [Select]
(if(Said 'open/door')
    (if(== aDoor DOOR_CLOSED)
(aDoor open:)
else
      (PrintItIs)
    )
)

Offline Kawa

Re: SCI0: doors
« Reply #3 on: April 20, 2023, 08:34:58 AM »
As far as I can tell, when you've determined which door is meant you can just (aDoor open:) without caring about its current state, or if the player is quite close enough.

If there's two doors on opposite ends of the room, a simple position check would suffice. Then you let the doors handle the details:
Code: [Select]
(if (Said 'open/door')
  (if (> (gEgo x?) 160) ; are we on the right half of the screen, where the bar door is?
    (aDoor open:) ; being right up to the door and already being opened is handled for us.
  )
)

Or if there's only the one door in this room, just (if (Said 'open/door') (aDoor open:) ) will do ya.


(The correct phrasing for what you tried to do, to check if the door is closed, is (if (== (aDoor doorState?) DOOR_CLOSED), by the way. What you did was try to compare an object reference to a small number, which would be like... "is 800 equal to 3".)

Offline robbo007

Re: SCI0: doors
« Reply #4 on: April 20, 2023, 08:47:52 AM »
That makes sense :) Thanks.

Offline robbo007

Re: SCI0: doors
« Reply #5 on: April 25, 2023, 12:31:33 PM »
Could you also use the position check with the gPreviousRoomNumber in a case you have two parts of the screen ego can exit off. Top part and bottom part. Both lead to same room but starting position on new room would be different. Or would you use control colours?

Code: [Select]
(cond
((== gPreviousRoomNumber 028)(gEgo posn: 311 102 loop: 1)
  )
  ((== gPreviousRoomNumber 028)(gEgo posn: 200 102 loop: 1)
  )
((== gPreviousRoomNumber 030)(gEgo posn: 182 97 loop: 2)
)
(else
(gEgo posn: 64 92 loop: 0)
)
)

Offline Kawa

Re: SCI0: doors
« Reply #6 on: April 25, 2023, 12:41:08 PM »
If you want Ego to appear in the right spot depending on which room they came from, gPreviousRoomNumber is your guy, always. That's exactly, specifically what that global is for.

The Door class uses control colors to figure out if Ego is close enough, and as far as I know, that's all.

Offline robbo007

Re: SCI0: doors
« Reply #7 on: April 26, 2023, 05:46:22 AM »
ok thanks for confirming that. So can you use two gPreviousRoomNumber entries for one "from room" as my code above? My "from room" has two exists which arrive to the same "to room" but I need ego to appear in two different positions when starting the room. If that makes sense. :)

Offline Kawa

Re: SCI0: doors
« Reply #8 on: April 26, 2023, 06:31:08 AM »
If it's one single room with two exits leading to the same single other room, you'll have to use different tactics to figure out which door it was.

Off the top of my head you might be able to check for Ego's position (just one of X or Y) and decide from there.


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

Page created in 0.118 seconds with 24 queries.