Reference
ModOptions
Global player preferences and shortcuts configurable from the NRF Hub tab of the game options.
Usage context
| Module | Package | SDK source |
|---|---|---|
| Kotlin/Native | nimby | kotlin/src/nimby/ModOptions.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.ModOption
import nimby.BooleanOption
import nimby.IntegerOption
import nimby.OptionChoice
import nimby.ChoiceOptionModOption
sealed class ModOption<T>Typed preference belonging to the mod and user, shared across the user’s games. Create a concrete type, register it with options(...) and read value. The SDK saves values and updates them between callbacks.
ModOption.id
val id: StringStable identifier unique within the mod: starts with an ASCII letter, then letters, digits, _, . or -, up to 128 characters. The window. prefix is reserved for the SDK.
ModOption.label
val label: StringNonempty label displayed in options, up to 256 UTF-8 bytes. Accepts tr; translating this text does not change identity.
ModOption.defaultValue
val defaultValue: TDeclared initial value, used when no compatible preference is saved and when resetting. Separate from the player’s current value.
ModOption.description
val description: StringOptional explanation, up to 1024 UTF-8 bytes; accepts tr. An empty string omits the explanation.
ModOption.value
val value: TRead-only current value, initially defaultValue. Read it in callbacks and rules without ToolContext. A local read with no game or disk access; invalid changes preserve accepted values.
BooleanOption
class BooleanOption(
id: String, label: String, defaultValue: Boolean = false, description: String = "",
) : ModOption<Boolean>Enabled or disabled preference, read as Boolean through value. defaultValue is false when omitted; label and description accept tr.
IntegerOption
class IntegerOption(
id: String, label: String, defaultValue: Int, val minimum: Int, val maximum: Int,
description: String = "",
) : ModOption<Int>Bounded integer preference, read as Int. minimum must be at most maximum, and defaultValue must lie within the inclusive range. Invalid values are rejected.
IntegerOption.minimum
val minimum: IntInclusive lower preference bound; a signed Kotlin Int.
IntegerOption.maximum
val maximum: IntInclusive upper preference bound; at least minimum.
OptionChoice
data class OptionChoice(val id: String, val label: String)Value offered by ChoiceOption: stable id saved in the preference and label displayed to the player. IDs are unique within a choice list.
OptionChoice.id
val id: StringIdentifier returned by ChoiceOption.value; follows the option ID format. Do not translate it or replace it with display text.
OptionChoice.label
val label: StringVisible choice text, nonempty and limited to 256 UTF-8 bytes; accepts tr.
ChoiceOption
class ChoiceOption(
id: String, label: String, choices: List<OptionChoice>, defaultValue: String,
description: String = "",
) : ModOption<String>Selection among two to sixteen distinct choices. defaultValue must be a choice id; value returns that String identifier, never its translated label.
ChoiceOption.choices
val choices: List<OptionChoice>Copy of declared choices in display order. Changing the list supplied to the constructor afterwards does not change this option’s choices.