Reference
Nimby
Client entry point: connection and functions grouped by purpose in Game.
Usage context
| Module | Package | SDK source |
|---|---|---|
| Kotlin/JVM | fr.nimby.sdk | kotlin-client/src/main/kotlin/fr/nimby/sdk/Nimby.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.Nimby
import fr.nimby.sdk.Game
import java.nio.file.Path
import java.time.InstantNimby
object NimbyJVM application entry point: discover games, then explicitly open a connection. A Native mod uses its SDK-provided context.
Nimby.runningGames
fun runningGames(): List<GameProcess>Lists visible game processes; selects none and does not guarantee a connection will succeed.
Nimby.connect
fun connect(sdk: Path, processId: Int? = null): GameOpens the specified SDK for the chosen PID. Without a PID, requires exactly one visible game. Returns a Game to close with use; no automatic mutation.
Game
class Game : AutoCloseableApplication-owned connection grouped by purpose. Use use to close it; copied observations remain readable after closing. Do not construct this type directly.
Game.advanced
val advanced: NimbyClientDetailed client for this same connection; do not close it separately.
Game.trains
val trains: TrainsTargeted reads and train queries.
Game.clock
val clock: ClockGame-clock reads and explicit date changes.
Game.signals
val signals: SignalsTemporary visual tests of signal textures.
Game.mods
val mods: ModsStatus and temporary control sessions for loaded mods.
Game.construction
val construction: ConstructionPreparation, creation, tracking and undo of experimental signal batches.
Game.snapshot
fun snapshot(selectedTrain: Long? = null): 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.
Game.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.
Game.Trains
class TrainsAccess to train reads on this connection. Obtain this object from Game.
Game.Trains.read
fun read(id: 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.
Game.Trains.read
fun read(id: TrainId): 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.
Game.Trains.snapshot
fun snapshot(selectedTrain: TrainId? = 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.
Game.Clock
class ClockAccess to the game clock on this connection. Obtain this object from Game.
Game.Clock.read
fun read(): 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.
Game.Clock.set
fun set(utc: 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.
Game.Signals
class SignalsDisplay actions only; do not change movement permissions. Obtain this object from Game.
Game.Signals.showTexture
fun showTexture(id: Long, catalogue: String, image: 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.
Game.Signals.restoreTexture
fun restoreTexture(id: Long): UnitRemoves the requested temporary visual override for this signal; does not rewrite mod rules.
Game.Mods
class ModsExplicit control of mods present in the connected game. Obtain this object from Game.
Game.Mods.status
fun status(id: String): ControlResponseQueries the mod loaded in this game once. Counts describe temporary overrides, not all managed signals. An exception is not proof the mod is absent.
Game.Mods.control
fun control(id: 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.
Game.Construction
class ConstructionExperimental ticket-based construction; every write must be confirmed and tracked. Obtain this object from Game.
Game.Construction.prepare
fun prepare(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.
Game.Construction.create
fun create(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.
Game.Construction.poll
fun poll(token: Long): ConstructionResultReads the existing ticket state without repeating creation or undo. Use a nonzero ticket from the same game/editing session.
Game.Construction.undo
fun undo(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.