NRF SDK 0.9

Reference

Nimby

Client entry point: connection and functions grouped by purpose in Game.

Usage context

ModulePackageSDK source
Kotlin/JVMfr.nimby.sdkkotlin-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.

Imports on this page
import fr.nimby.sdk.Nimby
import fr.nimby.sdk.Game
import java.nio.file.Path
import java.time.Instant

Nimby

fr.nimby.sdk · object
object Nimby

JVM application entry point: discover games, then explicitly open a connection. A Native mod uses its SDK-provided context.

Nimby.runningGames

fr.nimby.sdk · fun
fun runningGames(): List<GameProcess>

Lists visible game processes; selects none and does not guarantee a connection will succeed.

Nimby.connect

fr.nimby.sdk · fun
fun connect(sdk: Path, processId: Int? = null): Game

Opens 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

fr.nimby.sdk · class
class Game : AutoCloseable

Application-owned connection grouped by purpose. Use use to close it; copied observations remain readable after closing. Do not construct this type directly.

Game.advanced

fr.nimby.sdk · val
val advanced: NimbyClient

Detailed client for this same connection; do not close it separately.

Game.trains

fr.nimby.sdk · val
val trains: Trains

Targeted reads and train queries.

Game.clock

fr.nimby.sdk · val
val clock: Clock

Game-clock reads and explicit date changes.

Game.signals

fr.nimby.sdk · val
val signals: Signals

Temporary visual tests of signal textures.

Game.mods

fr.nimby.sdk · val
val mods: Mods

Status and temporary control sessions for loaded mods.

Game.construction

fr.nimby.sdk · val
val construction: Construction

Preparation, creation, tracking and undo of experimental signal batches.

Game.snapshot

fr.nimby.sdk · fun
fun snapshot(selectedTrain: Long? = null): 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.

Game.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.

Game.Trains

fr.nimby.sdk · class
class Trains

Access to train reads on this connection. Obtain this object from Game.

Game.Trains.read

fr.nimby.sdk · fun
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

fr.nimby.sdk · fun
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

fr.nimby.sdk · fun
fun snapshot(selectedTrain: TrainId? = 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.

Game.Clock

fr.nimby.sdk · class
class Clock

Access to the game clock on this connection. Obtain this object from Game.

Game.Clock.read

fr.nimby.sdk · fun
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

fr.nimby.sdk · fun
fun set(utc: 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.

Game.Signals

fr.nimby.sdk · class
class Signals

Display actions only; do not change movement permissions. Obtain this object from Game.

Game.Signals.showTexture

fr.nimby.sdk · fun
fun showTexture(id: Long, catalogue: String, image: 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.

Game.Signals.restoreTexture

fr.nimby.sdk · fun
fun restoreTexture(id: Long): Unit

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

Game.Mods

fr.nimby.sdk · class
class Mods

Explicit control of mods present in the connected game. Obtain this object from Game.

Game.Mods.status

fr.nimby.sdk · fun
fun status(id: String): ControlResponse

Queries 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

fr.nimby.sdk · fun
fun control(id: 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.

Game.Construction

fr.nimby.sdk · class
class Construction

Experimental ticket-based construction; every write must be confirmed and tracked. Obtain this object from Game.

Game.Construction.prepare

fr.nimby.sdk · fun
fun prepare(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.

Game.Construction.create

fr.nimby.sdk · fun
fun create(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.

Game.Construction.poll

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

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

Game.Construction.undo

fr.nimby.sdk · fun
fun undo(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.