getgamestate

Returns the game Lua state.

Syntax

getgamestate() -> LuaStateProxy?

Returns

TypeDescription
LuaStateProxy?The game state, or nil if it is unavailable

Description

getgamestate returns a LuaStateProxy for the game state.

Example

local gameState = assert(getgamestate(), "Game state is not available")
print("Game state ID:", gameState.Id)
print("Is Actor State:", gameState.IsActorState) -- false

Execute Code on Game State

local gameState = assert(getgamestate(), "Game state is not available")
gameState:Execute([[
    print("Executed on game state!")
]])

Compare States

local gameState = assert(getgamestate(), "Game state is not available")
local currentState = getluastate()

if gameState.Id == currentState.Id then
    print("Running on game state")
else
    print("Running on different state")
end