MIST scheduleFunction

From DCS World Wiki - Hoggitworld.com


mist.scheduleFunction

Added with: Mist 1.0
Description
This function schedules function f to run with the table vars unpacked (see the Lua unpack function in the Lua manual if you don’t know what “unpacked” means) and passed to it at the specified time of t. It also returns a number (that can used for cancelling the scheduled function call with mist.removeFunction). The optional value rep is the time between repetitions of the function. st defines when the function will stop automatically. If no vars need to be passed to the function, just set vars equal to an empty table ( {} ).
Syntax
number mist.scheduleFunction(function f ,table vars ,number t , number rep ,number st )
Valid Input Values:
function f: any function accessible to the scripting engine

table vars: input variables used for the called function

number t: time to run function (based on timer.getTime())

number rep: time between repetitions of this function (any positive number)

number st: time when repetitions of this function will stop automatically (based on timer.getTime())

Return value:
number
Return example:
5
Usage Examples:
The following would schedule mist.groupToRandomZone to call and move 'myGroup' to a random point in zone every 900 seconds up till 3600 seconds after the function was first called.

do

mist.scheduleFunction(mist.groupToRandomZone, {'myGroup', 'myZone'}, timer.getTime() + 10, 900, timer.getTime() + 3600)

end

Notes:
Related Functions
scheduleFunction, removeFunction, addEventHandler, removeEventHandler

Scripting Engine

MIST Root Page