/ HALion Developer Resource / HALion Script / Reference /

spawn

spawn(func, arg1, arg2, ...)

Description

Calls a Lua function and executes it in a separate, parallel thread.

Available in: Controller, Processor.

Arguments

ArgumentDescriptionValue Type
funcThe name of the function to be called.function
arg1, arg2, ...The arguments of the function.optional

Example

-- Play echos after releasing the note.

function echoNotes(event, echos)
    local duration = getBeatDuration()
    for i=1, echos do
        wait(duration*0.5)
        playNote(event.note+7*i, event.velocity*1/i, duration*0.25)
    end
    print("Spawn function of Note", event.note, "ended at", getTime())
end
 
function onNote(event)
    postEvent(event)
    waitForRelease()
    spawn(echoNotes, event, 3)
    print("Note", event.note, "was released at", getTime())
end

See also: runAsync, runSync, wait, waitBeat, waitForRelease