Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fnc_waitUntilAndExecute now can timeout for 0s #911

Merged
merged 3 commits into from
Apr 29, 2018
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As commy2 suggests, describe what timeout 0 and -1 will mean.


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