FFlags

Functions for reading and writing Fast Flags (FFlags), which are internal variables used by the game engine to control features and behavior.


game.GetFFlag(name, type)

Retrieves the value of a given FFlag, casting it to the specified type.

  • Parameters:

    • name: string - The case-sensitive name of the FFlag.

    • type: string - The expected data type of the FFlag. Must be one of "bool", "int", "float", or "double".

  • Returns:

    • any | nil: The value of the FFlag cast to the specified type, or nil if the flag is not found.

local physics_steps = game.GetFFlag("PhysicsStepsPerSecond", "float") 
if physics_steps ~= nil then
    print("Physics steps per second:", physics_steps)
end

-- Example of a non-existent flag
local not_found = game.GetFFlag("ThisFlagDoesNotExist", "int")
if not_found == nil then
    print("Correctly reported that the FFlag was not found.")
end

game.SetFFlag(name, value, type)

Sets the value of a given FFlag, writing it as the specified type.

  • Parameters:

    • name: string - The case-sensitive name of the FFlag.

    • value: any - The new value for the FFlag.

    • type: string - The data type to write the value as. Must be one of "bool", "int", "float", or "double".

  • Returns:

    • boolean: true if the FFlag was found and the value was written successfully, false otherwise.

-- Enable a boolean FFlag
local success = game.SetFFlag("DebugDrawBroadPhaseAABBs", true, "bool")
if success then
    print("Enabled broad phase debug drawing.")
end

-- Set the physics framerate
game.SetFFlag("PhysicsStepsPerSecond", 240.0, "float")

-- Set an integer value
game.SetFFlag("SomeIntegerValue", 100, "int")

Last updated