NRF SDK 0.9

Reference

NimbyClient

Connections, captures, targeted reads and commands for the Kotlin/JVM client.

Usage context

ModulePackageSDK source
Kotlin/JVMfr.nimby.sdkkotlin-client/src/main/kotlin/fr/nimby/sdk/NimbyClient.kt

Public API for SDK 0.9.0-alpha.2. Each entry provides the Kotlin signature and its contract: what the value means, conditions of use and effects to understand. Choose imports from the module shown above.

Imports on this page
import fr.nimby.sdk.NimbyClient
import java.nio.file.Path

NimbyClient

fr.nimby.sdk · class
class NimbyClient : ObservationClient

Detailed connection-owning client; prefer Game for common uses. Operations on this connection are serialized. Open through open and close with use; do not construct directly.

NimbyClient.Companion.open

fr.nimby.sdk · fun
fun open(libraryPath: Path, processId: Int): NimbyClient

Opens the given SDK library for a strictly positive PID and checks compatibility. Releases opening resources if connection fails.

NimbyClient.readTrain

fr.nimby.sdk · fun
fun readTrain(trainId: Long): DrivingObservation?

Reads only the requested train: position, measured speed and driving parameters. null if absent or unstable; other failures throw. The copied result remains usable after closing.

NimbyClient.prepareConstruction

fr.nimby.sdk · fun
fun prepareConstruction(sourceSignal: Long): ConstructionResult

Prepares a batch from an observed source signal and returns its ticket/state. Adds no signal. Revalidate the confirmed plan after preparation and before creation.

NimbyClient.createSignals

fr.nimby.sdk · fun
fun createSignals(token: Long, sourceSignal: Long, positions: List<Position>): ConstructionResult

Sends one creation with a prepared ticket and 1 to 64 distinct positions. Fractions strictly between 0 and 1, directions -1 or 1. Keep the ticket and poll after PENDING or an uncertain response; do not repeat create.

NimbyClient.undoConstruction

fr.nimby.sdk · fun
fun undoConstruction(token: Long): ConstructionResult

Requests one batch undo. May be refused if another command replaced the latest undoable operation. Check state and canUndo; follow an uncertain response with poll.

NimbyClient.pollConstruction

fr.nimby.sdk · fun
fun pollConstruction(token: Long): ConstructionResult

Reads the existing ticket state without repeating creation or undo. Use a nonzero ticket from the same game/editing session.

NimbyClient.readSimulationClock

fr.nimby.sdk · fun
fun readSimulationClock(): SimulationClock?

Reads the game clock without requesting large map tables with the current SDK. null when unavailable. Reuse snapshot.clock when a snapshot already exists.

NimbyClient.capture

fr.nimby.sdk · fun
override fun capture(selectedTrainId: Long?): Observation

Captures network tables and ordinary observations. A selected train adds its path and line plan; it does not filter the train list. Tables are copied without guaranteeing an atomic tick.

NimbyClient.captureTrainData

fr.nimby.sdk · fun
fun captureTrainData(selectedTrainId: Long? = null, query: TrainQuery = TrainQuery()): Observation

Specialised TrainQuery capture without full topology, signals, occupations or reservations. selectedTrain additionally requests its plan and service/timetable data; the train list remains a batch.

NimbyClient.setSimulationDateTime

fr.nimby.sdk · fun
fun setSimulationDateTime(utc: java.time.Instant, recalculateTrains: Boolean = false): SimulationTimeChange

Explicitly changes the UTC date in whole seconds. Preserves the subsecond fraction. recalculateTrains also requests train recalculation, with possible interventions. On failure, read again before any new write.

NimbyClient.showSignalTextureFor

fr.nimby.sdk · fun
fun showSignalTextureFor(signal: Long, catalogue: String, path: String, durationMillis: Int): Unit

Displays the declared catalogue image for 1,000 to 60,000 ms. Requires a real signal identity and nonempty paths. Changes appearance only, never rules or permissions.

NimbyClient.restoreSignalTexture

fr.nimby.sdk · fun
fun restoreSignalTexture(signal: Long): Unit

Removes the requested temporary visual override for this signal; does not rewrite mod rules.

NimbyClient.modControl

fr.nimby.sdk · fun
fun modControl(modId: String, request: ControlRequest): ControlResponse

Sends exactly one request to the named mod in the connected game. Prefer Game.mods and ModControlSession, which carry lease identity. Inspect state after failure before choosing a new mutation.

NimbyClient.acquireModControl

fr.nimby.sdk · fun
fun acquireModControl(modId: String, leaseMillis: Int = 5000): ModControlSession

Acquires an explicit 1,000 to 60,000 ms lease from a mod that has observed the game. Close with use; renewal and retries are never automatic.

NimbyClient.close

fr.nimby.sdk · fun
override fun close(): Unit

Closes this connection and releases its resources. Previously returned Kotlin copies remain valid as old observations; do not make further calls on this connection.