NRF SDK 0.9

Reference

ModControl

Scenario leases, temporary commands and mod responses.

Usage context

ModulePackageSDK source
Kotlin/JVMfr.nimby.sdkkotlin-client/src/main/kotlin/fr/nimby/sdk/ModControl.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.ControlOperation
import fr.nimby.sdk.TrainControlMode
import fr.nimby.sdk.TrainControlState
import fr.nimby.sdk.ControlRequest
import fr.nimby.sdk.ControlResponse
import fr.nimby.sdk.ModControlSession

ControlOperation

fr.nimby.sdk · class
enum class ControlOperation(val code: Int) {
    Status(0),
    Acquire(1),
    Renew(2),
    Release(3),
    ForceSignal(4),
    RestoreSignal(5),
    Train(6),
    RestoreTrain(7),
    Setting(8),
    RestoreSetting(9),
    Clear(10),
    ReadSignal(11),
    ReadTrain(12)
}

Temporary control operations. Prefer ModControlSession methods; aspect codes and checkbox indices are defined by the target mod.

ControlOperation.code

fr.nimby.sdk · val
val code: Int

Operation code sent by the client; use the enum without inventing a numeric value.

ControlOperation.Status

fr.nimby.sdk · enum-entry
Status(0)

Read mod status and override counts.

ControlOperation.Acquire

fr.nimby.sdk · enum-entry
Acquire(1)

Acquire the temporary control lease.

ControlOperation.Renew

fr.nimby.sdk · enum-entry
Renew(2)

Explicitly renew the existing lease.

ControlOperation.Release

fr.nimby.sdk · enum-entry
Release(3)

Release the lease and its overrides.

ControlOperation.ForceSignal

fr.nimby.sdk · enum-entry
ForceSignal(4)

Request a temporary aspect accepted by the mod.

ControlOperation.RestoreSignal

fr.nimby.sdk · enum-entry
RestoreSignal(5)

Remove a signal override.

ControlOperation.Train

fr.nimby.sdk · enum-entry
Train(6)

Request a temporary train constraint.

ControlOperation.RestoreTrain

fr.nimby.sdk · enum-entry
RestoreTrain(7)

Remove the temporary train constraint.

ControlOperation.Setting

fr.nimby.sdk · enum-entry
Setting(8)

Temporarily override a checkbox setting.

ControlOperation.RestoreSetting

fr.nimby.sdk · enum-entry
RestoreSetting(9)

Remove that checkbox override.

ControlOperation.Clear

fr.nimby.sdk · enum-entry
Clear(10)

Remove all lease overrides, without automatic renewal.

ControlOperation.ReadSignal

fr.nimby.sdk · enum-entry
ReadSignal(11)

Read the signal’s latest evaluated decision.

ControlOperation.ReadTrain

fr.nimby.sdk · enum-entry
ReadTrain(12)

Read train-constraint state; not a permission.

TrainControlMode

fr.nimby.sdk · class
enum class TrainControlMode(val code: Int) {
    SpeedLimit(0),
    PhysicalClearance(1),
    Stop(2)
}

Mode of a temporary test constraint. Speed must be finite and positive except for Stop, which requires zero. Game protections still apply.

TrainControlMode.code

fr.nimby.sdk · val
val code: Int

Mode code used by the client; choose a named enum value.

TrainControlMode.SpeedLimit

fr.nimby.sdk · enum-entry
SpeedLimit(0)

Numeric speed ceiling without requesting physical-clearance running.

TrainControlMode.PhysicalClearance

fr.nimby.sdk · enum-entry
PhysicalClearance(1)

Speed ceiling with physical-clearance checks; does not promise passage against every other protection.

TrainControlMode.Stop

fr.nimby.sdk · enum-entry
Stop(2)

Stop constraint, with speedMps equal to zero.

TrainControlState

fr.nimby.sdk · class
enum class TrainControlState {
    Absent,
    AwaitingExit,
    Active,
    Completed,
    Cancelled
}

Observed train-constraint state. readTrain.active corresponds to this enum; no state is a native movement permission.

TrainControlState.Absent

fr.nimby.sdk · enum-entry
Absent

No reported constraint.

TrainControlState.AwaitingExit

fr.nimby.sdk · enum-entry
AwaitingExit

Constraint awaiting its exit binding; can also indicate a request not yet observed as applied.

TrainControlState.Active

fr.nimby.sdk · enum-entry
Active

Constraint observed as active.

TrainControlState.Completed

fr.nimby.sdk · enum-entry
Completed

Constraint observed as completed.

TrainControlState.Cancelled

fr.nimby.sdk · enum-entry
Cancelled

Constraint cancelled after a route reset.

ControlRequest

fr.nimby.sdk · class
data class ControlRequest(
    val operation: ControlOperation, val owner: Long = 0, val generation: Long = 0,
    val leaseMillis: Int = 0, val objectId: Long = 0, val exitSignal: Long = 0,
    val speedMps: Double = 0.0, val mode: TrainControlMode = TrainControlMode.SpeedLimit,
    val releaseByRear: Boolean = false, val value: Int = 0, val settingIndex: Int = 0
)

Detailed control request. For ordinary test scenarios, ModControlSession supplies owner and generation and provides named methods. Do not invent a lease identity.

ControlRequest.operation

fr.nimby.sdk · val
val operation: ControlOperation

Requested action; determines relevant fields.

ControlRequest.owner

fr.nimby.sdk · val
val owner: Long = 0

Nonzero opaque lease identity for mutations; supplied by the control session.

ControlRequest.generation

fr.nimby.sdk · val
val generation: Long = 0

World generation observed by the mod; must match the lease.

ControlRequest.leaseMillis

fr.nimby.sdk · val
val leaseMillis: Int = 0

Requested lease duration for Acquire/Renew, from 1,000 to 60,000 ms.

ControlRequest.objectId

fr.nimby.sdk · val
val objectId: Long = 0

Observed identity of the target signal or train, according to the operation.

ControlRequest.exitSignal

fr.nimby.sdk · val
val exitSignal: Long = 0

Constraint-associated exit signal, or zero if no explicit exit is supplied.

ControlRequest.speedMps

fr.nimby.sdk · val
val speedMps: Double = 0.0

Requested ceiling in m/s: zero for Stop, strictly positive for other modes.

ControlRequest.mode

fr.nimby.sdk · val
val mode: TrainControlMode = TrainControlMode.SpeedLimit

Explicit train-constraint mode.

ControlRequest.releaseByRear

fr.nimby.sdk · val
val releaseByRear: Boolean = false

true: release after the rear passes the exit; false: after the head.

ControlRequest.value

fr.nimby.sdk · val
val value: Int = 0

Aspect code for ForceSignal; 0/1 for Setting. Meaning depends on operation and mod.

ControlRequest.settingIndex

fr.nimby.sdk · val
val settingIndex: Int = 0

Checkbox index in the target signal model; not a universal setting identity.

ControlResponse

fr.nimby.sdk · class
data class ControlResponse(
    val capabilities: Int, val generation: Long, val remainingMillis: Long,
    val signalCount: Int, val trainCount: Int, val settingCount: Int,
    val active: Int, val aspect: Int, val reason: Int,
    val speedMps: Double, val exitSignal: Long, val detail: String
)

Mod response to a request. Counts concern temporary overrides. active/aspect/reason depend on the operation; interpret them using the mod contract.

ControlResponse.capabilities

fr.nimby.sdk · val
val capabilities: Int

Capabilities advertised by the mod; does not prove a particular mutation will be accepted.

ControlResponse.generation

fr.nimby.sdk · val
val generation: Long

World generation currently observed by the mod.

ControlResponse.remainingMillis

fr.nimby.sdk · val
val remainingMillis: Long

Remaining lease duration in milliseconds; does not update within this copy.

ControlResponse.signalCount

fr.nimby.sdk · val
val signalCount: Int

Number of requested signal overrides, not managed signal count.

ControlResponse.trainCount

fr.nimby.sdk · val
val trainCount: Int

Number of requested temporary train constraints.

ControlResponse.settingCount

fr.nimby.sdk · val
val settingCount: Int

Number of temporarily overridden checkboxes.

ControlResponse.active

fr.nimby.sdk · val
val active: Int

For ReadTrain: TrainControlState. For ReadSignal: 0 not overridden, 1 override requested, 2 observed decision matches the override. Does not describe permission.

ControlResponse.aspect

fr.nimby.sdk · val
val aspect: Int

Aspect code of the latest read decision; meaning belongs to the mod model.

ControlResponse.reason

fr.nimby.sdk · val
val reason: Int

Reason code of the latest read decision; interpret using the target mod.

ControlResponse.speedMps

fr.nimby.sdk · val
val speedMps: Double

Ceiling associated with the read constraint in metres per second; not measured train speed.

ControlResponse.exitSignal

fr.nimby.sdk · val
val exitSignal: Long

Exit identity associated with the reported constraint.

ControlResponse.detail

fr.nimby.sdk · val
val detail: String

Text detail returned by the mod; useful in logs without replacing structured fields.

ModControlSession

fr.nimby.sdk · class
class ModControlSession : AutoCloseable

Temporary lease obtained through game.mods.control. Overrides do not rewrite saved settings. Expiration and closing release overlays; no automatic renewal or retries.

ModControlSession.modId

fr.nimby.sdk · val
val modId: String

Identity of the mod actually targeted by this session.

ModControlSession.owner

fr.nimby.sdk · val
val owner: Long

Opaque lease-owner identity supplied on acquisition.

ModControlSession.generation

fr.nimby.sdk · val
val generation: Long

Generation observed at acquisition; another game invalidates the session.

ModControlSession.renew

fr.nimby.sdk · fun
fun renew(leaseMillis: Int = 5000): ControlResponse

Explicitly renews this lease for 1,000 to 60,000 ms; does not silently recreate an expired lease.

ModControlSession.forceSignal

fr.nimby.sdk · fun
fun forceSignal(signal: Long, aspect: Int): ControlResponse

Requests a temporary indication on a signal known to the mod. Its model must accept the aspect; read the decision again to observe application.

ModControlSession.restoreSignal

fr.nimby.sdk · fun
fun restoreSignal(signal: Long): ControlResponse

Removes the signal override so the model can recalculate its decision.

ModControlSession.setSetting

fr.nimby.sdk · fun
fun setSetting(signal: Long, index: Int, value: Boolean): ControlResponse

Overrides a checkbox by its index in the signal model, without modifying its saved value.

ModControlSession.restoreSetting

fr.nimby.sdk · fun
fun restoreSetting(signal: Long, index: Int): ControlResponse

Removes this checkbox’s temporary override; the saved setting becomes the source again.

ModControlSession.constrainTrain

fr.nimby.sdk · fun
fun constrainTrain(train: Long, speedMps: Double, mode: TrainControlMode,
        exitSignal: Long = 0, releaseByRear: Boolean = false): ControlResponse

Requests a temporary constraint: finite speed in m/s, zero for Stop and positive otherwise. The train and any explicit exit must be known to the mod. Read state again; acceptance does not prove movement.

ModControlSession.restoreTrain

fr.nimby.sdk · fun
fun restoreTrain(train: Long): ControlResponse

Removes the temporary constraint requested for this train.

ModControlSession.readSignal

fr.nimby.sdk · fun
fun readSignal(signal: Long): ControlResponse

Reads the signal’s latest evaluated decision; neither forces a new evaluation nor renews the lease.

ModControlSession.readTrain

fr.nimby.sdk · fun
fun readTrain(train: Long): ControlResponse

Reads train-constraint state; active corresponds to TrainControlState, not permission.

ModControlSession.clear

fr.nimby.sdk · fun
fun clear(): ControlResponse

Removes all overlays from this session; does not replace close for releasing the lease.

ModControlSession.close

fr.nimby.sdk · fun
override fun close(): Unit

Requests release once, then closes the local session even if release fails. No further calls; expiry remains the override-recovery fallback.