Worker
From Crumbled World Wiki
Example Code
function done()
--Do stuff here
end
--Run exportScript.lua in a background thread.
local worker = Worker("MapEditor/exportScript.lua",false)
worker:addCallbackFinished(done)
Constructor
| function | description |
|---|---|
| Worker(string luaFilePath) | Create a worker thread and load the luascript thread is destroyed when create or update function returns false. |
| Worker(string luaFilePath, bool cycleWork) | Create a worker thread and load the luascript thread is destroyed when create or update function returns false.
If cycleWork is false the thread will run as fast as the cpu and other threads allows it. if cycleWork is set to true the lua code will be executed once every frame. |
Functions
| return | function | description |
|---|---|---|
| bool | successfullyLoaded() | Returns true if the luascript was successfully loaded. |
| bool | isWorking() | Returns true if the worker is still working |
| addCallbackFinished(nil luaFunction) | Add callback that is called when the worker is done. | |
| addCallbackUpdated(nil luaFunction) | Add callback that is called every time update function is done | |
| stop() | Stop the worker. if the worker is runing a luascript the luascript will run until its done. | |
| start() | start the worker. |