NRF SDK 0.9

Reference

ToolWindow

Public Kotlin SDK declarations.

Usage context

ModulePackageSDK source
Kotlin/Nativenimbykotlin/src/nimby/ToolWindow.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 nimby.ToolWindow
import nimby.ToolWindowEvent
import nimby.ToolClock
import nimby.ToolTimeChange

ToolWindow

nimby · class
data class ToolWindow(val id: String, val title: String, val shortcut: String)

Standalone tool-window declaration, accessible by shortcut while playing. Register it through ToolModBuilder.window; no selected signal is required.

ToolWindow.id

nimby · val
val id: String

Window identifier unique within the mod, received in ToolWindowEvent.window. Keep it stable across versions: the shortcut preference is attached to it. Do not translate this identifier.

ToolWindow.title

nimby · val
val title: String

Text used both as the window title and its shortcut label under the mod’s group in Options → NRF Hub. Accepts tr; a short title avoids repeating the mod name. Changing it does not change identity.

ToolWindow.shortcut

nimby · val
val shortcut: String

Initial shortcut in the format accepted by window(...); empty to disable. The player can change the binding in the SDK options. The declaration does not necessarily represent the current binding.

ToolWindowEvent

nimby · class
data class ToolWindowEvent(
    val window: String, val action: String, val values: Map<String, Int>,
    val sequence: Long, val worldId: String, val generation: Long,
)

Event supplied to a window handler. Valid fields are sent together on click, not on each keystroke. Use the same request to publish its corresponding form.

ToolWindowEvent.window

nimby · val
val window: String

Identifier of the declared window that produced this event.

ToolWindowEvent.action

nimby · val
val action: String

open when opening, then the identifier of the activated button. Button text does not define its handling.

ToolWindowEvent.values

nimby · val
val values: Map<String, Int>

Map of validated form integers at click time, keyed by field ID. An absent field must not be invented as zero.

ToolWindowEvent.sequence

nimby · val
val sequence: Long

Form/event sequence supplied by the SDK. Pass it through the received request; do not fabricate an event to reuse an old window.

ToolWindowEvent.worldId

nimby · val
val worldId: String

Event world identity, required to match ToolContext for showWindow.

ToolWindowEvent.generation

nimby · val
val generation: Long

Event session generation. A different generation requires rejecting the old form and its intentions.

ToolClock

nimby · class
data class ToolClock(val utcSeconds: Long, val elapsedMillis: Long)

Copied reading of two different times: UTC calendar and elapsed simulation time. Pause, acceleration and a date change must not be confused with the computer’s real time.

ToolClock.utcSeconds

nimby · val
val utcSeconds: Long

Game calendar in signed seconds since 1 January 1970 UTC. Convert with dateTime; this is not the computer’s system clock.

ToolClock.elapsedMillis

nimby · val
val elapsedMillis: Long

Elapsed simulation time in milliseconds. Use this unit to reason about simulation without interpreting it as a UTC date.

ToolTimeChange

nimby · class
data class ToolTimeChange(val clock: ToolClock, val interventions: Long)

Result of a calendar change: returned clock and recalculation-intervention count. A received response lets you display the resulting state without replaying the command.

ToolTimeChange.clock

nimby · val
val clock: ToolClock

Clock returned after the change, used to display the date actually obtained.

ToolTimeChange.interventions

nimby · val
val interventions: Long

Number of native interventions during train recalculation; zero for a simple calendar translation. Interventions may move trains and incur costs.