Newbie question...

AndyPanda 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 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)
)
)
)
AndyPanda 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 Hmm... I don't think that's a problem with the switch, then.
doan sephim where did you put in the code for the door and the character's init? ex. (door:init())
AndyPanda 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())

)

doan sephim 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.
AndyPanda 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 :)
doan sephim 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
AndyPanda Yay! ;D
Thanks a bunch, Doan. I'm beginning to get the grasp of the basics now. I love this program :D
AndyPanda 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 :)
doan sephim 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