Community

SCI Programming => SCI Syntax Help => Topic started by: Scavenger on February 11, 2017, 07:45:03 PM

Title: Can someone explain how to do blocking actions?
Post by: Scavenger on February 11, 2017, 07:45:03 PM
I've been messing around for the past day or so with SCI 1.1, and so far I really like it - it's way better than SCI0 for what I do, which is mostly VGA stuff.  I've been working through the tutorials and the help file getting used to the engine, but there's still something I've not got my head around, and that's stopping the game while an action takes place, say, if you have an example scene:

Man: "You should try the wine. It is on the table over there."
Ego: "I think I shall."
(Ego walks to table, picking up animation plays.)
(Wait a second or two)
Man: "To your health, good sir."
(Ego drinking animation.)
Ego: "Egad, this is poisoned!"

I know that in AGS, you could queue up Character.Say commands and animations like so:

Code: [Select]
cMan.Say ("You should try the wine. It is on the table over there.");
cEgo.Say ("I think I shall.");
cEgo.Walk (200,150,eBlock);
cEgo.LockView (EGO_TAKE);
cEgo.Animate (0,5,eBlock);
cEgo.UnlockView ();
Wait (80);
cMan.Say ("To your health, good sir.");
...etc...

But I'm not sure what the equivilent would be in SCI Script... I've managed to do a Script before (while running through the tutorial to make the ship move), so I'm certain it's something to do with those, but how I'd set it up so that the player can't interact while this is going on except to skip speech is beyond me. Any pointers to where I should look? Thanks in advance!
Title: Re: Can someone explain how to do blocking actions?
Post by: Kawa on February 11, 2017, 08:51:47 PM
You set HandsOff at the start, and HandsOn at the end.

I'm in bed right now, posting from my phone, so I can't/won't look up the details.
Title: Re: Can someone explain how to do blocking actions?
Post by: troflip on February 11, 2017, 09:03:58 PM
^^^ close enough for posting from bed.

(gGame handsOff:)


(gGame handsOn:)


You can see it used a bunch in SCI Quest.

Title: Re: Can someone explain how to do blocking actions?
Post by: Scavenger on February 11, 2017, 09:10:05 PM
Thanks! I'll try it out and see if I can't make something happen!
Title: Re: Can someone explain how to do blocking actions?
Post by: Kawa on February 12, 2017, 04:11:01 AM
Or rather, make something not happen.
Title: Re: Can someone explain how to do blocking actions?
Post by: Scavenger on February 12, 2017, 05:01:44 AM
Okay, I think I've worked it out, I did a really simple interaction to make the ego walk to a place and back again:

Code: [Select]
(instance guytalkScript of Script
(properties)

(method (changeState newState)
(= state newState)
(switch state
(0
(gGame handsOff:)
(gEgo setMotion: MoveTo 282 91 guytalkScript)
)
(1
(gEgo setMotion: MoveTo 174 174 guytalkScript)
)
(2
(gGame handsOn:)
)
)
)
)

And it seems to work! The game stops, the ego walks, the game waits til he gets there and he walks back again. This is how you're supposed to use the changestate method, right? I'm not doing this entirely wrong?
Title: Re: Can someone explain how to do blocking actions?
Post by: Kawa on February 12, 2017, 01:10:12 PM
That's about it yeah.
Title: Re: Can someone explain how to do blocking actions?
Post by: troflip on February 12, 2017, 01:18:20 PM
Two style choices I usually make:
    - When passing the "who cares" parameter to the setMotion (or setCycle or whatever) calls, I usually use self (http://scicompanion.com/Documentation/Compiler/selfsuper.html?highlight=self) instead of the hardcoded name of the script to cue. That way if I move the code to another Script, I don't need to remember to change anything (i.e. the code becomes more portable).
    - I usually use switchto (http://scicompanion.com/Documentation/Compiler/switchto.html) instead of switch for changeStates, that way I can easily add/remove states and not have to adjust the numbers. I still use switch if I need to refer to a specific state externally (i.e. check if guyTalkScript is in its 3rd state) - in this case I'll use an enum (http://scicompanion.com/Documentation/Compiler/define.html?highlight=enum) to give the switch states names.

Code: [Select]
(instance guytalkScript of Script
(properties)

(method (changeState newState)
(= state newState)
(switchto state
(
(gGame handsOff:)
(gEgo setMotion: MoveTo 282 91 self)
)
(
(gEgo setMotion: MoveTo 174 174 self)
)
(
(gGame handsOn:)
)
)
)
)
Title: Re: Can someone explain how to do blocking actions?
Post by: MusicallyInspired on February 12, 2017, 06:39:28 PM
I had no idea about switchto! That was SO annoying to deal with numbers with the standard switch!