Community
SCI Programming => SCI Syntax Help => Topic started by: Cloudee1 on November 02, 2013, 11:18:37 PM
-
Ok, I honestly can't see what it is that I am doing wrong here. For some reason, I can't get to state 2 in the code below. Case 0 and 1 run perfectly, but it just will not progress on to state 2
(instance fillingCup of Script
(properties)
(method (changeState newState)
= state newState
(switch (state)
(case 0 ProgramControl()
(send gEgo:setCycle(Walk)setMotion(MoveTo 165 132 fillingCup))
)
(case 1 (send gEgo:loop(3)cel(0))
(emptyCup:cel(4))
(pouringSoda:posn(141 105))
= seconds 5
)
(case 2 Print("A cup that large may take a long time to fill")
= seconds 7
)
I can't get seconds or cycles to work for whatever reason, but if I replace the line with a moveTo that triggers the next state, it progresses just fine.
(youdontwannaknow:setMotion(MoveTo 700 96 fillingCup)) // used as a timer
I have the bit in the features script commented out that lets me place and move actors off screen. And I am using my usual set of "use" scripts
(use "main")(use "controls")(use "cycle")(use "game")(use "feature")(use "obj")
-
That looks like it should work. Is there maybe an issue with ProgramControl()? Did you modify it based on this discussion: http://sciprogramming.com/community/index.php/topic,660.0.html
-
Perhaps you didn't use setScript(fillingCup) when you initialized your Props and Acts?
-
Doan, I didn't use setScript at init, but instead set it when the user clicks on the soda machine. At which time it does state 0 and state 1, just it stops there with cycles or seconds set.
(case 995 (send pEvent:type(evMOUSEBUTTON) claimed(TRUE))// get
//(if(... close enough
(if(not(puSoda))
(sodaMachine:setScript(fillingCup))
)
(else
Print(25 6)
)
//)
//(else
// Print("You are not close enough to operate the machine")
//)
)
Gumby, I do have the ProgramControl and PlayerControl modified, and it has been in the pnc template for a while now.
(procedure public (ProgramControl)
(User:canControl(FALSE)canInput(FALSE))
(send gEgo:setMotion(NULL))
= gProgramControl TRUE
= canTab FALSE
)
(procedure public (PlayerControl)
(User:canControl(TRUE)canInput(FALSE))
(send gEgo:setMotion(NULL))
= gProgramControl FALSE
= canTab TRUE
)
I guess, what really bugs me about this is that, using an actors moveto to trigger the next step works. Why is it that it can find case 2 and beyond that way but not with the seconds or cycles. Even worse, this problem seems to be specific to this room. In another room, I've got a changestate set up using seconds that works just fine.
(instance passerBy of Act(properties x -10 y 133 view 504 loop 0))
(instance passingBy of Script
(properties)
(method (changeState newState)
= state newState
(switch (state)
(case 0 = whichWalker Random(504 505)
(passerBy:view(whichWalker))
= seconds Random(4 12)
)
(case 1 (passerBy:setCycle(Walk) setMotion(MoveTo 330 133 passingBy)))
(case 2 = whichWalker Random(504 505)
(passerBy:view(whichWalker))
= seconds Random(8 16)
)
(case 3 (passerBy:setCycle(Walk) setMotion(MoveTo -10 133 passingBy)))
(case 4 (self:changeState(0)))
) // switch end
) // method end
) // instance end