Skip to main content

CreateAdvancedThread

This function was added in DSL 4

Description

Create any type of thread, using the same general rules as CreateThread.

Some threads can only be created using this function.

These threads run at different points in the game's execution, depending on the type specified. This allows for more control over when and how the thread operates within the game's lifecycle.

Any extra arguments (...) are passed to the thread function when the thread starts.

function CreateAdvancedThread(type, func, ...) --[[ ... ]] end

Parameters

  • type: string - The type of thread to create. This determines the thread's behavior and capabilities.
  • func: function|string - The function to run in the thread. If a string is provided, it refers to a function in the current script's environment.
  • ...: any - (Optional) Additional arguments that will be passed to the thread function when it starts.

Return Values

  • thread: thread - The thread object representing the newly created advanced thread. This can be used to control the thread, such as pausing or stopping it.

Example

local thread = CreateAdvancedThread('POST_WORLD', function()
while true do
-- Perform operations that need to run after the world is updated
Wait(0) -- Yield to prevent blocking the main thread
end
end)

See Also