getgamestate
Returns the default game Lua state.
Syntax
getgamestate() -> LuaStateProxyReturns
| Type | Description |
|---|---|
LuaStateProxy | The LuaStateProxy for the main game state |
Description
getgamestate returns the LuaStateProxy for the default game Lua state. This is the main execution environment where most game scripts run.
Example
local gameState = getgamestate()
print("Game state ID:", gameState.Id)
print("Is Actor State:", gameState.IsActorState) -- falseExecute Code on Game State
local gameState = getgamestate()
gameState:Execute([[
print("Executed on game state!")
]])Compare States
local gameState = getgamestate()
local currentState = getluastate()
if gameState.Id == currentState.Id then
print("Running on game state")
else
print("Running on different state")
endRelated Functions
getluastate- Get LuaStateProxy for a specific actor or scriptgetactorstates- Get all active LuaStateProxy objectsgetactors- Get all Actor instances