Lua
C++
Edit

SetGlobal

Syntax

SetGlobal(name, value)

Sets a global variable in the Lua state.

Parameters

Example

-- Set a global variable
SetGlobal("testvalue", "Hello")

-- Run a script that accesses and modifies the variable
ExecuteString("Print(testvalue) testvalue = testvalue..'!'")

-- Retrieve the variable
local o = GetGlobal("testvalue")

-- Check if the variable is a string and display its value
if type(o) == "string" then
    Print(o)
else
    Print("Variable is not a string.")
end
Copyright © 2006-2025 Leadwerks Software.
All rights reserved.
Leadwerks 4 Documentation