mirror of
https://github.com/acemod/ACE3.git
synced 2024-08-30 18:23:18 +00:00
Merge pull request #2254 from acemod/waitUntilAndExecute
Add WaitUntilAndExecute Function
This commit is contained in:
commit
040a63bd8f
@ -7,9 +7,9 @@
|
||||
// PFHs
|
||||
//////////////////////////////////////////////////
|
||||
|
||||
//Singe PFEH to handle execNextFrame and waitAndExec:
|
||||
//Singe PFEH to handle execNextFrame, waitAndExec and waitUntilAndExec:
|
||||
[{
|
||||
private "_entry";
|
||||
private ["_entry", "_deleted"];
|
||||
|
||||
//Handle the waitAndExec array:
|
||||
while {!(GVAR(waitAndExecArray) isEqualTo []) && {GVAR(waitAndExecArray) select 0 select 0 <= ACE_Time}} do {
|
||||
@ -27,6 +27,18 @@
|
||||
GVAR(nextFrameBufferA) = GVAR(nextFrameBufferB);
|
||||
GVAR(nextFrameBufferB) = [];
|
||||
GVAR(nextFrameNo) = diag_frameno + 1;
|
||||
|
||||
//Handle the waitUntilAndExec array:
|
||||
_deleted = 0;
|
||||
{
|
||||
// if condition is satisifed call statement
|
||||
if ((_x select 2) call (_x select 0)) then {
|
||||
// make sure to delete the correct handle when multiple conditions are met in one frame
|
||||
GVAR(waitUntilAndExecArray) deleteAt (_forEachIndex - _deleted);
|
||||
_deleted = _deleted + 1;
|
||||
(_x select 2) call (_x select 1);
|
||||
};
|
||||
} forEach GVAR(waitUntilAndExecArray);
|
||||
}, 0, []] call CBA_fnc_addPerFrameHandler;
|
||||
|
||||
|
||||
|
@ -181,6 +181,7 @@ PREP(unmuteUnit);
|
||||
PREP(useItem);
|
||||
PREP(useMagazine);
|
||||
PREP(waitAndExecute);
|
||||
PREP(waitUntilAndExecute);
|
||||
PREP(waveHeightAt);
|
||||
|
||||
PREP(translateToWeaponSpace);
|
||||
@ -282,11 +283,12 @@ PREP(hashListPush);
|
||||
|
||||
GVAR(syncedEvents) = HASH_CREATE;
|
||||
|
||||
//GVARS for execNextFrame and waitAndExec
|
||||
//GVARS for execNextFrame and waitAndExec and waitUntilAndExecute
|
||||
GVAR(waitAndExecArray) = [];
|
||||
GVAR(nextFrameNo) = diag_frameno;
|
||||
GVAR(nextFrameBufferA) = [];
|
||||
GVAR(nextFrameBufferB) = [];
|
||||
GVAR(waitUntilAndExecArray) = [];
|
||||
|
||||
GVAR(settingsInitFinished) = false;
|
||||
GVAR(runAtSettingsInitialized) = [];
|
||||
|
23
addons/common/functions/fnc_waitUntilAndExecute.sqf
Normal file
23
addons/common/functions/fnc_waitUntilAndExecute.sqf
Normal file
@ -0,0 +1,23 @@
|
||||
/*
|
||||
* Author: joko // Jonas
|
||||
* Executes a code once with after the Condition is True, using a PFH
|
||||
*
|
||||
* Argument:
|
||||
* 0: Condition <CODE>
|
||||
* 1: Code to execute <CODE>
|
||||
* 2: Parameters to run the code with <ARRAY,ANY,NIL>
|
||||
*
|
||||
* Return value:
|
||||
* None
|
||||
*
|
||||
* Example:
|
||||
* [{(_this select 0) == vehicle (_this select 0)}, {(_this select 0) setDamage 1;}, [ACE_player]] call ace_common_fnc_waitAndExecute
|
||||
*
|
||||
* Public: No
|
||||
*/
|
||||
#include "script_component.hpp"
|
||||
|
||||
TRACE_1("Adding",_this);
|
||||
|
||||
GVAR(waitUntilAndExecArray) pushBack _this;
|
||||
nil
|
Loading…
Reference in New Issue
Block a user