Header menu logo PhysicsSandbox

SimulationLifecycle Module

High-level simulation lifecycle control: reset, run, and ID generation.

Functions and values

Function or value Description

nextId arg1

Full Usage: nextId arg1

Parameters:
    arg0 : string

Returns: string Human-readable ID like "sphere-1", "box-3".

Generates the next sequential ID for a body with the given shape prefix.

arg0 : string
Returns: string

Human-readable ID like "sphere-1", "box-3".

Example

 let id1 = nextId "sphere"   // "sphere-1"
 let id2 = nextId "sphere"   // "sphere-2"
 let id3 = nextId "box"      // "box-1"
val id1: obj
val id2: obj
val id3: obj

resetSimulation arg1

Full Usage: resetSimulation arg1

Parameters:

Fully resets the simulation to a clean state with a ground plane and standard gravity.

Steps: pause → server-side reset (fallback to clearAll) → reset ID counters → add ground plane at Y=0 → set gravity (0, -9.81, 0) → sleep 100ms. Call at the start of every demo or experiment for a predictable starting state.

arg0 : Session

runFor arg1 arg2

Full Usage: runFor arg1 arg2

Parameters:

Runs the simulation for the specified duration, then pauses automatically.

arg0 : Session
arg1 : float
Example

 runFor session 3.0    // run for 3 seconds then pause

Type something to start searching.