Community

SCI Programming => SCI Community How To's & Tutorials => Topic started by: scott_furphies on October 12, 2020, 01:15:53 AM

Title: Global animations using changeState
Post by: scott_furphies on October 12, 2020, 01:15:53 AM
Hi all,
I've run into a problem with something I expected to be very straightforward, but perhaps I've got completely the wrong idea.

I want to set up some global animations for things the player can do in any room, eg drink a potion or open a map etc.
This is usually easy to implement in a room script using the Roomscript:changeState/switch method. I figured that I could do the same thing in my main script and activate the state I want with my global said statements. This works fine except it will only run the case which I call from the said statement without going to the next case after =cycles x or =seconds x.

Is there something fundamental I'm misunderstanding about the main script which makes this method not work here? Is there a better way to rig up global animations?

Thanks in advance for your help!

--Edit: I'm still interested to know the answer, but after thinking about this a lot I don't see the benefit of having animation in the main script, as opposed to copy/pasting it into every room script- surely the effect would be the same on the heap, plus i can think of a few situations where you don't want those global animations, eg underwater or in the dark.

Title: Re: Global animations using changeState
Post by: troflip on October 12, 2020, 05:33:47 PM
I can't think of any reason it would not work in the main script. But it seems like this would belong more in a Rgn (region).

I don't exactly understand your original problem:

Quote
This works fine except it will only run the case which I call from the said statement without going to the next case after =cycles x or =seconds x.

... but it sounds like you might be calling changeState on a script that already has cycles or seconds set on it. You probably want to zero those out before calling changeState.
Title: Re: Global animations using changeState
Post by: scott_furphies on October 13, 2020, 12:14:28 AM
I've been using the same syntax for calling a state change as I would usually use in a room script, only in Main for some reason it will only run the first case.

Today i tediously duplicated the code in every script for the global animations I wanted, which is good in some ways, as there will need to be modifications depending on the context, and bad in other ways, like if i make an alteration or correction later i will have to alter it in every instance.

I think it's better this way, since the block of code for these animations are short, and there are problems which arise when say, checking your watch while sitting down, which obviously needs a modification from the standing up version.

--EDIT: I've noticed a similar problem when trying to call a RoomScript:changeState from within a RoomScript case, like if I want to combine different animation loops for different purposes. The first case is called but it will never progress to the next case.

Once again, this is easily resolved by simply making more customised RoomScript cases.