Author Topic: Manually Change Image's State?  (Read 1699 times)

Is there a way to manually change an image's state? For instance, say I have a spear equipped. Here's it's state code for reference:

Code: [Select]
datablock ShapeBaseImageData(spearImage)
{

...

stateName[0] = "Activate";
stateTimeoutValue[0] = 0.1;
stateTransitionOnTimeout[0] = "Ready";
stateSequence[0] = "ready";
stateSound[0] = weaponSwitchSound;

stateName[1] = "Ready";
stateTransitionOnTriggerDown[1] = "Charge";
stateAllowImageChange[1] = true;

stateName[2] = "Charge";
stateTransitionOnTimeout[2] = "Armed";
stateTimeoutValue[2] = 0.7;
stateWaitForTimeout[2] = false;
stateTransitionOnTriggerUp[2] = "AbortCharge";
stateScript[2] = "onCharge";
stateAllowImageChange[2] = false;

stateName[3] = "AbortCharge";
stateTransitionOnTimeout[3] = "Ready";
stateTimeoutValue[3] = 0.3;
stateWaitForTimeout[3] = true;
stateScript[3] = "onAbortCharge";
stateAllowImageChange[3] = false;

stateName[4] = "Armed";
stateTransitionOnTriggerUp[4] = "Fire";
stateAllowImageChange[4] = false;

stateName[5] = "Fire";
stateTransitionOnTimeout[5] = "Ready";
stateTimeoutValue[5] = 0.5;
stateFire[5] = true;
stateSequence[5] = "fire";
stateScript[5] = "onFire";
stateWaitForTimeout[5] = true;
stateAllowImageChange[5] = false;
stateSound[5] = spearFireSound;
};

Say I am in middle of the Charge state. How could I cut the Charge state short, and skip to the Fire state?

To contextualize my inquiry, I am trying to create an image which can have variable delay. The idea is to have a function that is called before the Charge state which schedules another function which will switch to the Fire state. To vary the delay, I would simply change the delay in the aforementioned state-switching function.

My current solution is to have several copies of the same image with different stateTimeoutValues. For different delays, I switch out different images. But this is very cumbersome, and makes adjusting the delay via preferences even more cumbersome. It is not an ideal solution, so I want to explore this option.
« Last Edit: November 25, 2017, 10:49:13 AM by Platypi »

you could make use of stateTransitionOnAmmo/stateTransitionOnNoAmmo and then use setImageAmmo(slot,x) to trigger the change (more info here)

you could make use of stateTransitionOnAmmo/stateTransitionOnNoAmmo and then use setImageAmmo(slot,x) to trigger the change (more info here)
Looks promising. I'll play around with it later and see what I can come up with.

you can do it using %obj.setImageTrigger() iirc. theres a few addons that utilize this to force image changes, check a reloading-gun pack like T+T or H&K or something.

you can do it using %obj.setImageTrigger() iirc. theres a few addons that utilize this to force image changes, check a reloading-gun pack like T+T or H&K or something.
setImageTrigger is just for onTriggerDown/Up.

you could make use of stateTransitionOnAmmo/stateTransitionOnNoAmmo and then use setImageAmmo(slot,x) to trigger the change (more info here)

There's also stateTransitionOnLoaded and stateTransitionOnNotLoaded which can be changed with a method similar to like setImageLoaded

There's also stateTransitionOnLoaded and stateTransitionOnNotLoaded which can be changed with a method similar to like setImageLoaded
Though do take note, setting ammo false also sets loaded false, if I recall. Could be the other way around. I forget.
Found that out when experimenting with giving weapons an 'attack speed' trait that could be changed on the player.

Though do take note, setting ammo false also sets loaded false, if I recall. Could be the other way around. I forget.

Wow. That explains so much stuff I've had with the state system lmfao