Reference
NimbyClient
Connections, captures, targeted reads and commands for the Kotlin/JVM client.
Usage context
| Module | Package | SDK source |
|---|---|---|
| Kotlin/JVM | fr.nimby.sdk | kotlin-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.
import fr.nimby.sdk.NimbyClient
import java.nio.file.PathNimbyClient
class NimbyClient : ObservationClientDetailed 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
fun open(libraryPath: Path, processId: Int): NimbyClientOpens the given SDK library for a strictly positive PID and checks compatibility. Releases opening resources if connection fails.
NimbyClient.readTrain
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
fun prepareConstruction(sourceSignal: Long): ConstructionResultPrepares 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
fun createSignals(token: Long, sourceSignal: Long, positions: List<Position>): ConstructionResultSends 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
fun undoConstruction(token: Long): ConstructionResultRequests 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
fun pollConstruction(token: Long): ConstructionResultReads the existing ticket state without repeating creation or undo. Use a nonzero ticket from the same game/editing session.
NimbyClient.readSimulationClock
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
override fun capture(selectedTrainId: Long?): ObservationCaptures 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
fun captureTrainData(selectedTrainId: Long? = null, query: TrainQuery = TrainQuery()): ObservationSpecialised 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
fun setSimulationDateTime(utc: java.time.Instant, recalculateTrains: Boolean = false): SimulationTimeChangeExplicitly 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
fun showSignalTextureFor(signal: Long, catalogue: String, path: String, durationMillis: Int): UnitDisplays 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
fun restoreSignalTexture(signal: Long): UnitRemoves the requested temporary visual override for this signal; does not rewrite mod rules.
NimbyClient.modControl
fun modControl(modId: String, request: ControlRequest): ControlResponseSends 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
fun acquireModControl(modId: String, leaseMillis: Int = 5000): ModControlSessionAcquires 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
override fun close(): UnitCloses this connection and releases its resources. Previously returned Kotlin copies remain valid as old observations; do not make further calls on this connection.