Reading and acting
Read and change simulation time
Distinguish game time, elapsed duration and real-world time, then apply an explicit change.
Read the time relevant to the calculation
In a connected JVM application, game.clock.read() returns a nullable SimulationClock without requesting the whole map. Use clock.toInstant() for its UTC date. If a batch is already available, snapshot.clock avoids another read and retains the time associated with that batch.
| Time | Use |
|---|---|
| SimulationClock.toInstant() | Simulation date; its origin may precede 1970. |
| SimulationClock.ticks | Simulation duration since the origin, in hundredths of a second. |
| capturedAtMillis | Real capture timestamp from the computer, in UTC milliseconds. |
| Interface refresh delay | Real-world cadence chosen by your application; independent of game speed. |
Pausing freezes simulation time without freezing real-world time. Acceleration changes their ratio. For mod animations and decisions, use the simulation time appropriate to the callback; to limit an external screen’s refresh rate, use a monotonic real-world duration.
Choose the effects before confirming
| Mode | Effect |
|---|---|
| recalculateTrains = false | Shifts the date while preserving positions and relative delays. |
| recalculateTrains = true | Also requests game recalculation; movements and costs may result. |
val chosenUtc = Instant.parse("2030-05-12T14:30:00Z")
val result = game.clock.set(chosenUtc, recalculateTrains = false)
println(result.clock.toInstant())
println(result.interventions)The requested date is a UTC Instant in whole seconds: nano must be zero. The simulation’s subsecond phase is preserved, so the returned time need not fall exactly on the requested second. interventions reports recalculation interventions, not a count of trains read.