NRF SDK 0.9

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.

TimeUse
SimulationClock.toInstant()Simulation date; its origin may precede 1970.
SimulationClock.ticksSimulation duration since the origin, in hundredths of a second.
capturedAtMillisReal capture timestamp from the computer, in UTC milliseconds.
Interface refresh delayReal-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

ModeEffect
recalculateTrains = falseShifts the date while preserving positions and relative delays.
recalculateTrains = trueAlso requests game recalculation; movements and costs may result.
JVM fragment: execute after the date and mode have been confirmed
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.