« Changelog 26/09/2009 | New to ArmA 2: The "3ms-break" » |
The "3ms-break" - Addition
In this addition I want to hint for an improvement or better: fault correction of the previous blog entry.
A fault?
Yes, I'm surprised too, just that few?
...
I wrote that two triggers are required for toggling a script without the 3ms break. This is wrong, one trigger is enough.
We set one variable as condition. In activation we call our script and set the variable to false. This will raise the deactivation part of the trigger on the next check. So we set the variable to true to activate the trigger again.
With multiple activation, this trigger will fire constantly.
To activate our script every x seconds, we set our trigger time out to x-1.
Why x-1?
Trigger will get checked approximately every half a second. On deactivation requires another half a second. So we have one second our trigger requires to fire again.
We can minimize this to half a second by running our script in the deactivation section too, but I don't know a way to reduce this future, at least with trigger.
Without trigger?
The following code is from an experiment:
Code:
Bla addEventHandler ["Engine", {_this spawn {(_this select 0) engineOn (not (_this select 1))}; Player sideChat str time}]; |
What does this script does?
It will add an eventhandler to a vehicle named Bla. As soon as the engine status changes, the handler will fire and toggle the engine again. This is done via spawn, which prevents a loop.
This script will fire every 0.1 second, at least on my system
It's not exactly every frame, but much better than 0.5 seconds.
No feedback yet
