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.
Signature
Section titled “Signature”local sim = ac.getSim()Description
Section titled “Description”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.
Return Value
Section titled “Return Value”| Type | Description |
|---|---|
ac.StateSim | A reference to the global simulation state. |
Technical Notes
Section titled “Technical Notes”- 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. Accessingsim.cameraPositionis significantly faster than calling a function to calculate it.
Examples
Section titled “Examples”local sim = ac.getSim()
function script.windowMain() ui.text(string.format("Time: %02d:%02d", sim.timeHours, sim.timeMinutes)) ui.text("Frame: " .. sim.frame)endlocal sim = ac.getSim()
function script.update() if sim.rainIntensity > 0.5 then -- trigger heavy rain logic (e.g., sound effects or wipers) endend