Skip to main content

CoroutineTools.WaitUntil(function controlFunc, [optionalArguments] params)

Suspends the coroutine execution until the supplied function evaluates to true.

Parameters:

NameTypeDescription
controlFuncfunctionThe Control function. The coroutine suspended until this function returns true.
params[optionalArguments]Zero or more values to be passed to the control function.

Usage

---@type function
local controlFunc;

---@type [optionalArguments]
local params;


CoroutineTools:WaitUntil(controlFunc, params)

Example

Notice that there is no requirement to prefix yield return or anything else to front of this function (unlike C# counterpart in the Unity. Any values passed after the control function will be passed to the control function. Example bellow, we are passing the control function called Control and passing a value of 50 which gets passed to control function parameter max. You can pass 0 or more parameters to passed to the control function.

do
local scp = LUA.script;
local num = 0;

-- add to number until reached max
local function Control(max)
num = num + 1;
return num == max;
end

local function coro()
CoroutineTools.WaitUntil(Control, 50);
end

function scp.Start()
scp.StartCoroutine(coro);
end
end