Problems with this script

Robin_Gravel The ego tries to cross a bridge when a guard's shouting to the ego.
The guard tells to the ego: "He you! Come in!"
The ego walks to the guard
The guard speaks"You can't cross the bridge by now."



Here my script:


/******************************************************************************/
(include "sci.sh")
(include "game.sh")
/******************************************************************************/
(script 19)
/******************************************************************************/
(use "controls")
(use "cycle")
(use "door")
(use "feature")
(use "game")
(use "inv")
(use "main")
(use "obj")
/******************************************************************************/
(local
hohoho=0
)
(instance public rm019 of Rm
(properties
picture scriptNumber
north 0
east 18
south 0
west 20
)
(method (init)
(super:init())
(self:setScript(RoomScript))

(switch(gPreviousRoomNumber)
(case east
(send gEgo:
posn(310 send gEgo:y)
loop(1)
)
)
(case west
(send gEgo:
posn(10 170)
loop(0)
)
)
)

SetUpEgo()
(send gEgo:init())
(Guard1:
init()
)
(Guard2:
init()
)
)
)
/******************************************************************************/
(instance RoomScript of Script
(properties)
(method (changeState newState)
= state newState
(switch (state)
(case 0
(if (== hohoho 0)
return
)
)
(case 1
Print("Eh you! Come here!" #title"Guard #2:" #icon 44 2 0)
= cycles 1
)
(case 2
(send gEgo:
setMotion(MoveTo 92 175 RoomScript)
)
= cycles 15
)
(case 3
//(drapeau2:show())
Print("Don't cross the bridge! King's Modigor's orders!" #title"Guard #2:" #icon 44 2 0)
= hohoho 0
return
)
)
)
(method (doit)
(super:doit())
(if(== (send gEgo:onControl()) ctlGREEN)
(if (== scenario 3)
(if(== hohoho 0)
= hohoho 1
= cycles 1
)
)
)
)
)
(instance Guard1 of Act
(properties
x 77
y 181
view 45
loop 0
)
)
(instance Guard2 of Act
(properties
x 80
y 160
view 45
loop 0
)
)


The script works once but after the ego crosses the bridge anyway.

Thanks in advance

Robin Gravel
cloudee1 Hey boss I don't know if this makes any difference or not but here is sumthin I saw:

(method (doit)
(super:doit())
(if(== (send gEgo:onControl()) ctlGREEN)
(if (== scenario 3)
(if(== hohoho 0)
= hohoho 1
= cycles 1
)))))


what is "scenario 3" I think you want "case 3" Isn't that the one where he crosses the bridge?
Robin_Gravel Hi cloudee1

scenario is a variable. It does not mean case. If it is set to anoter number, the ego can cross the bridge.

Robin Gravel
Robin_Gravel
Where is "scenario 3" deifined?


In the main.sc. scenario is a global variable in the game.


Robin Gravel



Robin_Gravel I found the problem.

Here the correct code:

/******************************************************************************/
(include "sci.sh")
(include "game.sh")
/******************************************************************************/
(script 19)
/******************************************************************************/
(use "controls")
(use "cycle")
(use "door")
(use "feature")
(use "game")
(use "inv")
(use "main")
(use "obj")
/******************************************************************************/
(local
hohoho=0
)
(instance public rm019 of Rm
(properties
picture scriptNumber
north 0
east 18
south 0
west 20
)
(method (init)
(super:init())
(self:setScript(RoomScript))

(switch(gPreviousRoomNumber)
(case east
(send gEgo:
posn(310 send gEgo:y)
loop(1)
)
)
(case west
(send gEgo:
posn(10 170)
loop(0)
)
)
)

SetUpEgo()
(send gEgo:init())
(Guard1:
init()
)
(Guard2:
init()
)
)
)
/******************************************************************************/
(instance RoomScript of Script
(properties)
(method (changeState newState)
= state newState
(switch (state)
(case 0
(if (== hohoho 0)
return
)
)
(case 1
Print("Eh you! Come here!" #title"Guard #2:" #icon 44 2 0)
= cycles 1
)
(case 2
(send gEgo:
setMotion(MoveTo 92 175 RoomScript)
)
= cycles 15
)
(case 3
//(drapeau2:show())
Print("Don't cross the bridge! King's Modigor's orders!" #title"Guard #2:" #icon 44 2 0)
= hohoho 0
return
)
)
)
(method (doit)
(super:doit())
(if(== (send gEgo:onControl()) ctlGREEN)
(if (== scenario 3)
(if(== hohoho 0)
= hohoho 1
= cycles 1
= state 0
)
)
)
)
)
(instance Guard1 of Act
(properties
x 77
y 181
view 45
loop 0
)
)
(instance Guard2 of Act
(properties
x 80
y 160
view 45
loop 0
)
)


Thanks anyway cloudee1

Robin Gravel
cloudee1 Bonjour Robin

Alright you seem to have mastered this room change state procedure, I am currently trying to master the room state change but I just keep staring at it hoping the knowledge of what to do will come to me, so far it hasn't.

so here is really where I would like some guidance, if you can.

so here is my handle script, at the point where it checks if TRAP_SET I think I want it to switch to case 1 but how do I trigger?

(if(Said('use/hand/pipe'))
(if (not(SCRAPE_RESIN))
(if(send gEgo:has(INV_HAND))
(if(send gEgo:has(INV_PIPE))
(send gTheMusic:number(107)loop(1)priority(-1)play())
(send gGame:changeScore(6))
(send gEgo:loop(6)setCycle(Fwd))
=SCRAPE_RESIN TRUE
(if (not(TRAP_SET))
Print("Digging around in your pipe with the hand from the clock produces quite a chunk of resin in the bowl!")
Print("Seeing that glob of resin gives you an idea")
(aMan:setPri(8)setCycle(Walk)setMotion(Follow gEgo))
)(else Print("Digging around in your pipe with the hand from the clock produces quite a chunk of resin in the bowl!")
Print("Seeing that glob of resin gives you an idea"))
)(else Print("Uhm what pipe are you referring to?"))
)(else Print("You are missing the necesary tools!"))
)(else Print("Desperate as you may be no more resin can be scraped!"))
)



ps also while ego finishes his digging in the pipe how do i keep him from being controlable and then switch him back to regular view, loop 2, as is he scrapes then won't walk right, animation is stuck.
Robin_Gravel It's hard to help you just with your code.

May I suggest to send your game to me with scripts and I'll check it out.

Send me at: robingravel@chez.com


Robin Gravel

Robin_Gravel

I want to get it started


When the ego enters in a room?


Robin Gravel
cloudee1 Nah not like title screen but when ego has done something, I figured out generally how to change my state but of course there is still more to learn, for example:
IN CASE 1

loop(6) is an animation of ego scraping out his pipe,
I have setCycle (fwd) and he don't never stop, and it effects the way his regular loops play when you move him, but how can I tell it to play loop(6) twice then back to regular loop(2)

(switch (state)
(case 0(if (not(SMOKE))return))
(case 1(if (not(SCRAPE_RESIN))
(send gEgo:loop(6)setCycle(Fwd))
=cycles 8
=SCRAPE_RESIN TRUE
return))
(case 2(if (TRAP_SET) return))
(case 3(aRat:setPri(8)setCycle(Walk)setMotion(Follow gEgo))= cycles 15)
(case 4
Print("Hello there my good man!")
= cycles 10)
(case 5
Print("I couldn't help but notice that you have pulled out your pipe!")
= cycles 10
return )
)
)


It's not complete in action but it is a working foundation.
Robin_Gravel Let me see

(switch (state)
(case 0
(if (not(SMOKE))
return
)
= cycles 2
)
(case 1
(if (not(SCRAPE_RESIN))
(send gEgo:
loop(6)
setCycle(Fwd)
)
=cycles 8
=SCRAPE_RESIN TRUE
//return // don't put return here or the routine might stopped here.
)
)
(case 2
(if (TRAP_SET)
return
)
= cycles 2
)
(case 3
(aRat:
setPri(8)
setCycle(Walk)
setMotion(Follow gEgo)
)
(send gEgo:
loop(2)
setCycle(Fwd)
)
= cycles 15
)
(case 4
Print("Hello there my good man!")
= cycles 10
)
(case 5
Print("I couldn't help but notice that you have pulled out your pipe!")
= cycles 10
//return //You don't need this return since it's the last case unless you need more cases in your game
)
)
I'm not sure if my code works.


Robin Gravel
cloudee1 No see this room has a whole lot of action in it, I have several different state changes to go through, so where that return was is the end of that state, I want it to return to regular play at that point.

So I got this stuff to change the state:

(instance RoomScript of Script
    (properties)
(method (changeState newState)
= state newState
(switch (state)
(case 0(if (not(SMOKE))return))
(case 1(if (not(SCRAPE_RESIN))
(send gEgo:loop(6)setCycle(Fwd))
=cycles 42
=SCRAPE_RESIN TRUE))
(case 2 (send gEgo:loop(2)setCycle(Walk))
=cycles 1
Print ("Blah Blah Blah!")
return)
(case 3(if (TRAP_SET)) return)
(case 4(aRat:setPri(8)setCycle(Walk)setMotion(Follow gEgo))= cycles 15)
(case 5
Print("Blah Blah Blah!")
= cycles 10)
(case 6
Print("Blah Blah Blah!")
= cycles 10
return )
)
)

And I got this to start the state changes:

(if(Said('use/hand/pipe'))
(if (not(SCRAPE_RESIN))
(if(send gEgo:has(INV_HAND))
(if(send gEgo:has(INV_PIPE))
(send gTheMusic:number(107)loop(1)priority(-1)
play())
(send gGame:changeScore(6))
= state 0
= cycles 1
Print("Blah Blah Blah!")
)(else Print("Blah Blah Blah?"))
)(else Print("Blah Blah Blah!"))
)(else Print("Blah Blah Blah!"))
)
(if(Said('use/lighter/pipe,resin'))
(if (not(TRAP_SET))
(if (not(SMOKE))
=SMOKE_WITH_RAT TRUE
=SMOKE TRUE
= cycles 1
= state 3
)(else Print("You have smoked all of the resin!"))
)(else Print("Blah Blah Blah!")
Print("Blah Blah Blah!")
Print("Blah Blah Blah!")
=SMOKE TRUE)
)

and so far so good everything seems to be working pretty well, but know I'm going to try and take away control of ego during animations, and then give it back when they are over. I know I've seen it somewhere I just need to track it down.

p.s. I deleted some of my miscellaneous postings