Volt

getgamestate

Returns the default game Lua state.

Syntax

getgamestate() -> LuaStateProxy

Returns

TypeDescription
LuaStateProxyThe 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) -- false

Execute 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")
end

On this page