Community
SCI Programming => SCI Syntax Help => Topic started by: gumby on January 06, 2013, 07:47:25 PM
-
I can't seem to get these to both work together in the same room script. When I attempt to have both methods in my room, it seems to break the 'state progression' counter. The doit() still operates normally, but the 'state' variable used in the changeMethod never gets incremented.
-
Just a shot in the dark, but can you increment it in the doit()? If so, perhaps you could do it indirectly by having the changeState() populate a temporary variable that the doit() could read to increment the state variable.
-
You may have to post some code for this one Gumby. I don't recall ever having trouble with having a doit and a changestate in the same room stepping on each other.
In fact I usually have several changestates operating at the same time in conjunction with a couple of things that the doit method is watching for.
-
I'm wondering if this is a result of the timer bug not being fixed in the game template that I'm using. I'll check this later today & see if the bug fix is in there or not.
-
Shot in the dark - if your doit() method is the trigger of the changeState() it will do so every cycle unless you have something that changes.
(method(doit)
(super:doit)
(if(& (send gEgo:onControl()) ctlBROWN)
(RoomScript:changeState(2))
)
)This code for instance seems like it would trigger the changeState when Ego is on ctlBROWN, but actually the changeState won't progress until he is on Brown and then steps off.
To avoid this, I usually just add a variable
(method(doit)
(super:doit)
(if(& (send gEgo:onControl()) ctlBROWN)
(if(not(brownTrigger))
(RoomScript:changeState(2))
= brownTrigger 1
)
)
)
-
Here's what I have. If I remove the doit() method, I can reach state 6. Otherwise, I never get to state 6. I've checked and the timer bug is already fixed. You can try this code in a new template game:
(instance RoomScript of Script
(properties)
(method (doit)) // yeah, I know it's empty. Remove this & changeState will work properly
(method (changeState mainState)
= state mainState
(switch(state)
(case 0)
(case 5
= seconds 3
)
(case 6
Print("State 6!")
)
)
)
(method (handleEvent pEvent)
(super:handleEvent(pEvent))
/*****************************************
* Handle the possible said phrases here *
*****************************************/
(if(Said('look'))
(RoomScript:changeState(5))
)
)
)
So to test, run the game and type 'look'. After 3 seconds you should get the 'State 6!' message pop up, IF you've removed the doit(). Otherwise the print statement never displays.
EDIT: Nevermind, I found the issue! I needed this:
(method (doit)
(super:doit) // this is somewhat critical!
)
-
I was just about to point that out before I noticed your edit. The super doit...
Thought your doit method looked a little sparse :)