Skip to content

getSim

The primary function for retrieving the global state of the simulation. It returns an ac.StateSim object containing everything from graphics settings to weather conditions and session timing.

local sim = ac.getSim()

ac.getSim() provides a reference to a persistent FFI structure. This structure is updated once per graphics frame. It is the central source of truth for the environment, camera, and session progress.

TypeDescription
ac.StateSimA reference to the global simulation state.
  • Update Rate: This data is updated at the rendering rate (FPS). For physics-rate data, refer to specialized physics namespaces.
  • Memory: Like ac.getCar, this returns a pointer. Accessing sim.cameraPosition is significantly faster than calling a function to calculate it.

local sim = ac.getSim()
function script.windowMain()
ui.text(string.format("Time: %02d:%02d", sim.timeHours, sim.timeMinutes))
ui.text("Frame: " .. sim.frame)
end