Reference
ModServices
Declare a tool or an action available when another mod is loaded.
Usage context
| Module | Package | SDK source |
|---|---|---|
| Kotlin/Native | nimby | kotlin/src/nimby/ModServices.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 nimby.SignalAction
import nimby.SignalActionRequest
import nimby.GameMod
import nimby.ToolMod
import nimby.ToolModBuilder
import nimby.toolModSignalAction
data class SignalAction(val id: String, val label: String, val whenMod: String, val service: String)Optional signal button connected to a tool-mod service. An absent provider hides the button without removing the signal or changing its rules.
SignalAction.id
val id: StringStable action identifier, unique among the model’s actions. Sent to the service on click.
SignalAction.label
val label: StringButton text in the signal panel; accepts tr and remains separate from id.
SignalAction.whenMod
val whenMod: StringTechnical identifier of the provider mod. Controls button availability without requiring its installation.
SignalAction.service
val service: StringExact service identifier declared by the provider through service(...). It is not a Kotlin function name.
SignalActionRequest
data class SignalActionRequest(
val sequence: Long, val signalId: Long, val action: String, val service: String,
val worldId: String, val generation: Long,
val panelToken: Long = 0, val originAction: String = action,
val value: Int? = null,
)Event supplied to the service after a signal action. Retain its session and panel information when responding; a click alone does not validate a construction plan.
SignalActionRequest.sequence
val sequence: LongNumber of the received event. Use the supplied request to associate your response with this action; do not fabricate a sequence.
SignalActionRequest.signalId
val signalId: LongSelected source signal. It can later be deleted or changed; revalidate before a mutation.
SignalActionRequest.action
val action: StringIdentifier of the activated button or edited field in the panel. The service must explicitly select the corresponding action.
SignalActionRequest.service
val service: StringTarget service declared by the tool mod. Subsequent events from the same panel return to this service.
SignalActionRequest.worldId
val worldId: StringIdentity of the game world that produced the event. A request from another world cannot present or confirm the current plan.
SignalActionRequest.generation
val generation: LongSession generation to compare with the current context. Invalidate plan and preview when it changes.
SignalActionRequest.panelToken
val panelToken: Long = 0Opaque identity of the originating panel. Pass the received request to presentation methods instead of reconstructing this token.
SignalActionRequest.originAction
val originAction: String = actionInitial action that opened the panel, preserved when action becomes one of that panel’s buttons or fields.
SignalActionRequest.value
val value: Int? = nullNew validated integer from a numeric field; null for a button. Empty or invalid input is not replaced with zero.
GameMod
abstract class GameModCommon base for signalling and tool mods. createMod returns a DSL-declared implementation; a tool does not need a signal model.
GameMod.id
abstract val id: StringStable mod identifier, used by whenMod to reach its services. Reuse modInfo.id rather than a translated label.
GameMod.title
abstract val title: StringDeclared mod title, used to group its preferences and shortcuts in Options → NRF Hub. Comes from modInfo.title with the modInfo overload; metadata(name=...) does not replace it. Identity remains id.
GameMod.metadata
open val metadata: ModMetadata?Presentation information declared through metadata; null when none is supplied. Does not describe tool rules.
GameMod.options
open val options: List<ModOption<*>>Explicit mod options, empty by default. Retain their objects to read value. The limit of 64 includes window shortcuts added automatically by the SDK.
GameMod.windows
open val windows: List<ToolWindow>Windows declared by the mod. Empty when none are declared; opening them requires no selected signal.
GameMod.onWindowEvent
open fun onWindowEvent(request: ToolWindowEvent, context: ToolContext): UnitHandles a window event with a context valid only during this call. The DSL routes the event to the handler for request.window.
GameMod.services
open val services: List<String>Identifiers of services registered by the mod. External actions must use these exact identifiers.
GameMod.onSignalAction
open fun onSignalAction(request: SignalActionRequest, context: ToolContext): UnitHandles a signal action in its target service. Keep the callback short, validate the session and do not retain ToolContext after returning.
GameMod.onTick
open fun onTick(context: ToolContext): UnitPeriodic callback to advance bounded work, renew presentation or poll a ticket. It does not guarantee an exact frequency; return without waiting.
GameMod.onStop
open fun onStop(): UnitReleases local state and resources during a normal mod shutdown. No ToolContext is supplied; do not rely on this callback after an abrupt termination.
ToolMod
class ToolMod : GameModTool mod constructed through toolMod. Its services and windows receive events without defining signalling aspects or rules; construction is reserved for the SDK.
ToolMod.id
override val id: StringStable mod identifier, used by whenMod to reach its services. Reuse modInfo.id rather than a translated label.
ToolMod.title
override val title: StringDeclared mod title, used to group its preferences and shortcuts in Options → NRF Hub. Comes from modInfo.title with the modInfo overload; metadata(name=...) does not replace it. Identity remains id.
ToolMod.metadata
override val metadata: ModMetadata?Presentation information declared through metadata; null when none is supplied. Does not describe tool rules.
ToolMod.windows
override val windows: List<ToolWindow>Windows declared by the mod. Empty when none are declared; opening them requires no selected signal.
ToolMod.options
override val options: List<ModOption<*>>Explicit mod options, empty by default. Retain their objects to read value. The limit of 64 includes window shortcuts added automatically by the SDK.
ToolMod.services
override val services: List<String>Identifiers of services registered by the mod. External actions must use these exact identifiers.
ToolMod.onSignalAction
override fun onSignalAction(request: SignalActionRequest, context: ToolContext): UnitHandles a signal action in its target service. Keep the callback short, validate the session and do not retain ToolContext after returning.
ToolMod.onTick
override fun onTick(context: ToolContext): UnitPeriodic callback to advance bounded work, renew presentation or poll a ticket. It does not guarantee an exact frequency; return without waiting.
ToolMod.onStop
override fun onStop(): UnitReleases local state and resources during a normal mod shutdown. No ToolContext is supplied; do not rely on this callback after an abrupt termination.
ToolMod.onWindowEvent
override fun onWindowEvent(request: ToolWindowEvent, context: ToolContext): UnitHandles a window event with a context valid only during this call. The DSL routes the event to the handler for request.window.
ToolModBuilder
class ToolModBuilderConfiguration received inside toolMod: services, windows, metadata and lifecycle callbacks. The SDK creates this builder; do not instantiate it directly.
ToolModBuilder.options
fun options(vararg values: ModOption<*>): UnitRegisters one or more global preferences; multiple calls append options. Rejects duplicate IDs and more than 64 options including window shortcuts. Keep the declared objects to read their value.
ToolModBuilder.window
fun window(id: String, title: String, shortcut: String = "F8", handler: ToolContext.(ToolWindowEvent) -> Unit): UnitRegisters a standalone window and handler, up to 8 distinct IDs. The SDK creates its player-configurable shortcut option: F8 by default, empty to disable. Format: optional Ctrl+, Alt+, Shift+ in that order followed by A–Z, 0–9, F1–F24 or a named key from the guide. Nonempty shortcuts within the mod must be distinct. showWindow supplies the content.
ToolModBuilder.metadata
fun metadata(author: String, description: String, name: String? = null): UnitDeclares the author, description and optional name for the game’s mod lists and details. name and description accept tr. Replaces neither the group heading in Options → NRF Hub nor window titles; identity comes from mod.json.
ToolModBuilder.service
fun service(id: String, handler: ToolContext.(SignalActionRequest) -> Unit): UnitRegisters a service with a unique identifier, up to 32 per mod. A mod’s callbacks are serialized; a blocking handler delays that same mod’s other tasks.
ToolModBuilder.onTick
fun onTick(block: ToolContext.() -> Unit): UnitDeclares periodic tool work. Process only pending tasks and return; avoid a full network read and waiting on every tick.
ToolModBuilder.onStop
fun onStop(block: () -> Unit): UnitDeclares local cleanup during normal shutdown. Must not retain or use a context from an earlier callback.
toolMod
fun toolMod(id: String, title: String, block: ToolModBuilder.() -> Unit): ToolModBuilds a tool with an explicit identity and at least one service or window. In a Gradle project, prefer toolMod(modInfo) to use the generated identity.