Blockland Forums > Modification Help
Manually Change Image's State?
Platypi:
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: ---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;
};
--- End code ---
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.
otto-san:
you could make use of stateTransitionOnAmmo/stateTransitionOnNoAmmo and then use setImageAmmo(slot,x) to trigger the change (more info here)
Platypi:
--- Quote from: otto-san on November 25, 2017, 05:14:45 PM ---you could make use of stateTransitionOnAmmo/stateTransitionOnNoAmmo and then use setImageAmmo(slot,x) to trigger the change (more info here)
--- End quote ---
Looks promising. I'll play around with it later and see what I can come up with.
Conan:
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.
Shift Kitty:
--- Quote from: Conan on November 25, 2017, 09:05:18 PM ---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.
--- End quote ---
setImageTrigger is just for onTriggerDown/Up.