Skip to content

Commit

Permalink
Merge pull request #911 from felixlinker/patch-1
Browse files Browse the repository at this point in the history
fnc_waitUntilAndExecute now can timeout for 0s
  • Loading branch information
Killswitch00 committed Apr 29, 2018
2 parents b982e79 + 92a9619 commit eebfc48
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions addons/common/fnc_waitUntilAndExecute.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,15 @@ Function: CBA_fnc_waitUntilAndExecute
Description:
Executes a code once in unscheduled environment after a condition is true.
It's also possible to add a timeout, in which case a different code is executed.
It's also possible to add a timeout >= 0, in which case a different code is executed.
Then it will be waited until _timeout time has elapsed or _condition evaluates to true.
Parameters:
_condition - The function to evaluate as condition. <CODE>
_statement - The function to run once the condition is true. <CODE>
_args - Parameters passed to the functions (statement and condition) executing. (optional) <ANY>
_timeout - Timeout for the condition in seconds. (optional) <NUMBER>
_timeout - If >= 0, timeout for the condition in seconds. If < 0, no timeout.
Exactly 0 means timeout immediately on the next iteration.(optional, default -1) <NUMBER>
_timeoutCode - Will execute instead of _statement if the condition times out. (optional) <CODE>
Passed Arguments:
Expand Down Expand Up @@ -37,11 +39,11 @@ params [
["_condition", {}, [{}]],
["_statement", {}, [{}]],
["_args", []],
["_timeout", 0, [0]],
["_timeout", -1, [0]],
["_timeoutCode", {}, [{}]]
];

if (_timeout == 0) then {
if (_timeout < 0) then {
GVAR(waitUntilAndExecArray) pushBack [_condition, _statement, _args];
} else {
GVAR(waitUntilAndExecArray) pushBack [{
Expand Down

0 comments on commit eebfc48

Please sign in to comment.