Vital.sandbox
Engine

engine.load_string

Shared

Executes a buffer within the engine


Syntax

local result = engine.load_string(buffer, autoload = true)

Parameters

TypeNameDescription
stringbufferBuffer containing code to be loaded and executed
boolautoloadDetermines execution behavior:
• When true - the loaded function executes immediately
• When false - returns a callable function for deferred execution

Returns

TypeNameDescription
function / boolresult• When autoload is false - returns the loaded function on success, or false on failure
• When autoload is true - returns true on successful execution, or false on failure

Examples

--Immediate execution with autoload enabled
local success = engine.load_string([[
    engine.print("Immediate", "Execution")
]], true)
--Deferred execution with autoload disabled
local exec = engine.load_string([[
    engine.print("Delayed", "Execution")
]], false)

if exec then
    exec() --Execute the loaded function manually
end

On this page