Author Topic: Newbie question...  (Read 6642 times)

0 Members and 1 Guest are viewing this topic.

Offline AndyPanda

Newbie question...
« on: June 08, 2004, 07:58:46 AM »
Ok, I downloaded SCI studio yesterday. I have almost no programming skills at all, but _almost_ got through the tutorial without any problem. Now it just won't compile, and I don't know why (cause I'm a lousy programmer  ;D). Here's the code:

            /******************************************************
             * Put the cases here for the rooms ego can come from *
             ******************************************************/
(switch(gPreviousRoomNumber)
  (case 2
    (send gEgo:
      posn(195 110)
      loop(2)
    )
  )
)
            // Set up ego's position if it hasn't come from any room
           (default
              (send gEgo:
                 posn(150 130)
                 loop(1)
              )
                                               )
                                           )



It "works" if I delete one out-bracket at the end of the switch, but then that switch won't process at all, when I enter the room again, and the room is empty (no Brian, no door).  I hope you can help me, even though I'm not good at explaining my problem   ::)



Endroz

  • Guest
Re:Newbie question...
« Reply #1 on: June 08, 2004, 08:16:37 AM »
Hi,
I believe you should also delete the close bracket after the first case, like this:

(switch (gPreviousRoomNumber)
  (case 2
    (send gEgo:
      posn(195 110)
      loop(2)
    )
  )

 // Set up ego's position if it hasn't come from any room
  (default
    (send gEgo:
       posn(150 130)
       loop(1)
    )
  )
)

Offline AndyPanda

Re:Newbie question...
« Reply #2 on: June 08, 2004, 08:22:43 AM »
Did that. But when I enter room 2, and go back to room 1, the door I put there, and the other character is gone  ::)

Endroz

  • Guest
Re:Newbie question...
« Reply #3 on: June 08, 2004, 08:30:28 AM »
Hmm... I don't think that's a problem with the switch, then.

Offline Doan Sephim

Re:Newbie question...
« Reply #4 on: June 08, 2004, 09:52:22 AM »
where did you put in the code for the door and the character's init? ex. (door:init())

Offline AndyPanda

Re:Newbie question...
« Reply #5 on: June 08, 2004, 10:18:05 AM »
Here:

   (method (init)
      // same in every script, starts things up
        (super:init())
        (self:setScript(RoomScript))
        (if(not (send gEgo:has(INV_KEY)))
        (theKey:
        init()
        setCycle(Fwd)
        setPri(0)
        )
        (aMan:
        init()
        setCycle(Walk)
        setMotion(Wander))
        (aDoor:init())

)


Offline Doan Sephim

Re:Newbie question...
« Reply #6 on: June 08, 2004, 10:56:14 AM »
hmmm...i think i need to see the entire script to determine what is wrong. i suspect it is just a mis-placed bracket somewhere b/c that is what i used to do alot when i started scripting.

Offline AndyPanda

Re:Newbie question...
« Reply #7 on: June 08, 2004, 11:00:49 AM »
Ok, here goes (this is the rm001 script):

/******************************************************************************
 SCI Template Game
 By Brian Provinciano
 ******************************************************************************
 rm001.sc
 Contains the first room of your game.
 ******************************************************************************/
(include "sci.sh")
(include "game.sh")
/******************************************************************************/
(script 1)
/******************************************************************************/
(use "main")
(use "controls")
(use "cycle")
(use "game")
(use "feature")
(use "obj")
(use "inv")
(use "door")
(use "jump")
(use "dpath")
(use "wander")
/******************************************************************************/
(instance public rm001 of Rm
   (properties
      picture scriptNumber
      // Set up the rooms to go to/come from here
      north 0
      east 0
      south 0
      west 0
   )
   (method (init)
      // same in every script, starts things up
        (super:init())
        (self:setScript(RoomScript))
        (if(not (send gEgo:has(INV_KEY)))
        (theKey:
        init()
        setCycle(Fwd)
        setPri(0)
        )
        (aMan:
        init()
        setCycle(Walk)
        setMotion(Wander))
        (aDoor:init())

)
        // Check which room ego came from and position it

            /******************************************************
             * Put the cases here for the rooms ego can come from *
             ******************************************************/
(switch (gPreviousRoomNumber)
  (case 2
    (send gEgo:
      posn(195 110)
      loop(2)
    )
  )

// Set up ego's position if it hasn't come from any room
  (default
    (send gEgo:
      posn(150 130)
      loop(1)
    )
  )
)




      // Set up the ego
      SetUpEgo()      
      (send gEgo:init())

        /****************************************
         * Set up the room's music to play here *
         ****************************************/ /*
      (send gTheMusic:
         prevSignal(0)
         stop()
         number(scriptNumber)
         loop(-1)
         play()
      )*/

        /**************************************************
         * Add the rest of your initialization stuff here *
         **************************************************/
  )
)
/******************************************************************************/
(instance RoomScript of Script
   (properties)
   (method (handleEvent pEvent)
        (super:handleEvent(pEvent))

     (if(Said('take/key'))
  (if(send gEgo:has(INV_KEY))
    Print("You already have it!")
  )(else
    (if(send gEgo:inRect(150 150 170 170))
      Print("O.K.")
      (send gEgo:get(INV_KEY))
      (theKey:hide())
    )(else
      Print("You're not close enough!")
    )
  )
)
(if(Said('open/door'))
  (if(send gEgo:has(INV_KEY))
    (aDoor:locked(FALSE))
  )(else
    (aDoor:locked(TRUE))
  )
  (aDoor:open())
)
(if(Said('close/door'))
  (aDoor:close())
)
(if(Said('talk/man'))
  (if(< (send gEgo:distanceTo(aMan)) 40)
    Print("Hello Brian!" #title "You Say:")
    Print("Hello there! Welcome to SCI Studio!" #title "Brian Says:")
  )(else
    Print("You don't want to yell. Get closer.")
  )
)

        /*****************************************
         * Handle the possible said phrases here *
         *****************************************/
        (if(Said('look'))
            Print("You are in an empty room")
        )
    )
)
(instance theKey of Prop
  (properties
    y 160
    x 160
    view 400
  )
)
(instance aMan of Act
  (properties
    y 170
    x 220
    view 1
  )
)
(instance aDoor of Door
  (properties
    y 100
    x 195
    view 2
    entranceTo 2
    locked TRUE
  )
)


I appreciate your help  :)

Offline Doan Sephim

Re:Newbie question...
« Reply #8 on: June 08, 2004, 11:13:15 AM »
ohhh...here might be something...this is what you have:
(if(not (send gEgo:has(INV_KEY)))
        (theKey:init()setCycle(Fwd)setPri(0))
        (aMan:
        init()
        setCycle(Walk)
        setMotion(Wander))
        (aDoor:init())
it is only "init-ing" the man and the door when you dont have the key.
it needs to be like this:
(if(not (send gEgo:has(INV_KEY)))
        (theKey:init()setCycle(Fwd)setPri(0))
)
(aMan:init()setCycle(Walk)setMotion(Wander))
(aDoor:init())

that means that you need to get rid of the out bracket you have hanging after "(Door:init())"...the one that looks like it is closing the init method.
the reason it only happens when you come back from room 2 is because (i assume) you have to take the key to get to room 2 and once you have it the init method you have is saying ok he has the key so the key, (and the door and man) do not need "init-ing" (initializing if you want to use real words). i think that should work.
doan

Offline AndyPanda

Re:Newbie question...
« Reply #9 on: June 08, 2004, 11:30:49 AM »
Yay!  ;D
Thanks a bunch, Doan. I'm beginning to get the grasp of the basics now. I love this program  :D

Offline AndyPanda

Re:Newbie question...
« Reply #10 on: June 08, 2004, 12:20:21 PM »
Just one more thing (sorry if I'm a pain in the butt  :P):

I have a background music that play when I'm in a certain room. But whenever I do a action in that room, the music stops. How do I make the music continue regardless of what happens?

edit: I just found out that the problem is that this only happens if I do something that raises the score. But it would be nice though, if the music kept playing after that :)
« Last Edit: June 08, 2004, 12:30:26 PM by AndyPanda »

Offline Doan Sephim

Re:Newbie question...
« Reply #11 on: June 08, 2004, 09:32:02 PM »
you can make it so that when you raise the score there is no sound effects. you have to edit the main script. find (method(changeScore addScore) a little under half-way down into the script - i bet you can figure it out form there.
doan


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

Page created in 0.04 seconds with 15 queries.