Author Topic: setting an Image's trigger almost instantly reverts the trigger back to 0  (Read 2449 times)

Code: [Select]
if(%slot == 4 && %val && %player.getMountedImage(1) && %player.getImageState(1) $= "Ready")
{
%player.setImageTrigger(1,1);
%player.playThread(3, leftRecoil);
}
if(%slot == 4 && !%val && %player.getMountedImage(1))
{
%player.setImageTrigger(1,0);
%player.playthread(3, armReadyLeft);
}
When using this code (or for that matter, using player.setImageTrigger(1,1); at all), the trigger's state is almost instantly set back to 0. The only time it seems to still be active is when using player.getImageTrigger(1); in the same line of code.
I'm unsure what causes this -- using the same function for slot 0 stays at 1 until it is commanded to do otherwise.
Any idea what may be causing this?

What are you trying to do?

This is because the client tells the engine in the next frame that they are not pressing the trigger, so it gets set to 0. Try it on an AIPlayer for comparison.

This is because the client tells the engine in the next frame that they are not pressing the trigger, so it gets set to 0. Try it on an AIPlayer for comparison.
That seems to be the case. Would you happen to know what procedure it uses to go back to 0? GameConnection didn't seem to have any (directly) related functions, and it's not using %player.setImageTrigger() to revert back.

That seems to be the case. Would you happen to know what procedure it uses to go back to 0? GameConnection didn't seem to have any (directly) related functions, and it's not using %player.setImageTrigger() to revert back.
Why do you need the image trigger to stay activated?

This script will give the ability to use items in your left hand.

This script will give the ability to use items in your left hand.

If the client triggers that themselves, just add a keybind that does this:

function fireSecondary(%state)
{
    $mvTriggerAction[1] += %state ? 1 : -1;
}
« Last Edit: August 16, 2014, 05:00:45 AM by portify »

There's no way to intercept the signal serverside?

There's no way to intercept the signal serverside?

Well there's a callback for when the client presses/release a trigger, of course (onTrigger). There's no way to immediately overwrite the value so that the engine disregards it in plain TorqueScript.

altTrigger() is a client-side built-in function like that one, fires left hand slot but doesn't have a keybind by default. (should work on e.g. Guns Akimbo)

setImageAmmo() is an alternative if you need to force actions on a custom weapon, use stateTransitionOn[No]Ammo.

setImageAmmo() is an alternative if you need to force actions on a custom weapon, use stateTransitionOn[No]Ammo.

Alternatively stateTransitionOn[Not]Loaded and setImageLoaded() if that's already in use.