Author Topic: Open door sez good idea  (Read 6192 times)

0 Members and 1 Guest are viewing this topic.

Offline King Graham

Open door sez good idea
« on: April 02, 2007, 01:21:11 PM »
Hey everybody!

I've used the door-code of the tutorial, but if i type "open door" or "close door" it sez: "Good idea. You can try that again later." and the door stays closed. So i cant come in anymore

 ??? Help plz!



Offline troflip

Re: Open door sez good idea
« Reply #1 on: April 02, 2007, 01:36:30 PM »
Can you post your *exact* code for your handleEvent method?
Check out my website: http://icefallgames.com
Groundhog Day Competition

Offline King Graham

Re: Open door sez good idea
« Reply #2 on: April 03, 2007, 01:59:29 PM »
Just as in the tutorial, but without the locked code.

        (if(Said('open/door'))
         (aDoor:open())
        )
        (if(Said('close/door'))
         (aDoor:close())
        )

Offline troflip

Re: Open door sez good idea
« Reply #3 on: April 03, 2007, 02:14:56 PM »
That code is fine, but it is obviously never being hit.  You'll have to post your entire script.
Check out my website: http://icefallgames.com
Groundhog Day Competition

Offline King Graham

Re: Open door sez good idea
« Reply #4 on: April 04, 2007, 07:36:08 AM »
Here it is
Code: [Select]
/******************************************************************************/
(include "sci.sh")
(include "game.sh")
/******************************************************************************/
(script 2)
/******************************************************************************/
(use "controls")
(use "cycle")
(use "door")
(use "feature")
(use "game")
(use "inv")
(use "main")
(use "obj")
/******************************************************************************/
(instance public rm002 of Rm
(properties
picture scriptNumber
north 0
east 3
south 0
west 0
)
(method (init)
(super:init())
(self:setScript(RoomScript))
        (aDoor:init())
        (aPasserby:
         setScript(passingBy)
         xStep(3)
         setPri(-1)
         ignoreActors()
         illegalBits(0)
         init()
         hide()
        ) // #1
(switch(gPreviousRoomNumber)
            (case 3
            (send gEgo:
posn(310 137)
loop(1)
)
            )
            (default
(send gEgo:
posn(141 117)
loop(2)
)
)
)

SetUpEgo()
(send gEgo:init())

)
)
/******************************************************************************/
(instance RoomScript of Script
(properties)
    (method (doit)
   )
    (method (handleEvent pEvent)
        (super:handleEvent(pEvent))

        /*****************************************
         * Handle the possible said phrases here *
         *****************************************/
        (if(Said('look'))
         Print("You are outside.")
        )
        (if(Said('open/door'))
         (aDoor:open())
        )
        (if(Said('close/door'))
         (aDoor:close())
        )
    )
)
/******************************************************************************/
(instance aDoor of Door
  (properties
    x 145
    y 106
    view 10
    entranceTo 1
    roomCtrl $4000
  )
)
/**************************************************************************/
(instance aPasserby of Act(properties x 0 y 137 view 1 loop 0))
/**************************************************************************/
(instance passingBy of Script
(properties)
  (method (changeState newState)
  = state newState
    (switch (state)
      (case 0 (aPasserby:setPri(3)hide()) = seconds Random(3 8))
      (case 1 (aPasserby:show()view(1)setPri(-1)setLoop(0)posn(0 137)setCycle(Walk)setMotion(MoveTo 320 137 passingBy)))
      (case 2 (aPasserby:hide()) = seconds Random(2 6))
      (case 3 (aPasserby:show()view(2)setPri(-1)setLoop(0)posn (0 137)setCycle(Walk)setMotion(MoveTo 320 137 passingBy)))
      (case 4 (aPasserby:hide()) = seconds Random(2 10))
      (case 5 (aPasserby:show()view(3)setPri(-1)setLoop(0)posn (0 137)setCycle(Walk)setMotion(MoveTo 320 137 passingBy)))
      (case 6 (aPasserby:setPri(11)hide()) = seconds Random(2 6))
      (case 7 (aPasserby:show()view(4)setPri(-1)setLoop(0)posn (0 137)setCycle(Walk)setMotion(MoveTo 320 137 passingBy)))
      (case 8 (self:changeState(0)))
    ) // switch end
  ) // end method
) // end instance

Offline Doan Sephim

Re: Open door sez good idea
« Reply #5 on: April 04, 2007, 10:18:59 AM »
Here's what I'm thinking. That code looks pretty normal to me...I only looked though it in entirety once, so I may have missed something.

But only in the mainscript is the property that says "Good idea. You can try that again later" used. My guess is that you edited the mainscript at some point. This is very important:

If you ever edit the mainscript, you must compile ALL scripts, or else all kinds of unexpected things tend to happen.

That is my guess. So, just use the "compile all scripts" function, rebuild, and run the game to see if the problem is fixed "on its own".
« Last Edit: April 04, 2007, 10:20:51 AM by Doan Sephim »
Artificial Intelligence Competition

Offline King Graham

Re: Open door sez good idea
« Reply #6 on: April 04, 2007, 11:04:45 AM »
I did what you suggested and... Well, it does'nt say 'Good Idea.' anymore, but now it says 'You're not close enough.' even if i am in front of the door. Hmmm... strange.

Offline troflip

Re: Open door sez good idea
« Reply #7 on: April 04, 2007, 11:07:50 AM »
Sounds like that was the problem then.

"You're not close enough" is the door script telling you that the ego is not standing on the door control colour (navy blue).
« Last Edit: April 04, 2007, 11:10:28 AM by troflip »
Check out my website: http://icefallgames.com
Groundhog Day Competition

Offline King Graham

Re: Open door sez good idea
« Reply #8 on: April 04, 2007, 11:10:43 AM »
Green  ??? I thought $4000 was yellow!

Offline Doan Sephim

Re: Open door sez good idea
« Reply #9 on: April 04, 2007, 11:49:29 AM »
I think it is yellow, but doesn't the door script assign yellow ($4000) as the block color? why not use a color like grey or silver or maroon? If yellow is assigned as the blocking color (as it is in the door script) then your ego would never actually be on that color unless the door was open, so you would never be close enough.

Another way to approach this without using control colors at all is check whether ego is close to the door by using code like:

Code: [Select]
(if(Said('open/door'))
  (if(<=(send gEgo:distanceTo(door))25)
    (door:open())
  )
)

I am not 100% sure that will work because I don't actually use the door script at all...I just use doors like any other Prop...

Offline troflip

Re: Open door sez good idea
« Reply #10 on: April 04, 2007, 11:54:26 AM »
The door control property by default is doorCtrl, which is  ($0002), which is ctlNAVY (see my correction above).

ctlYELLOW is the default door block ($4000)... e.g. the area your ego can't walk through when the door is closed.

Look at how the sample room pics are done...

You can also do what Doan suggested, but you need to set the force property of the door to TRUE.

« Last Edit: April 04, 2007, 11:57:39 AM by troflip »
Check out my website: http://icefallgames.com
Groundhog Day Competition

Offline King Graham

Re: Open door sez good idea
« Reply #11 on: April 04, 2007, 12:55:31 PM »
 ;D Good! Doan's idea worked! Thanks!


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

Page created in 0.069 seconds with 23 queries.