NRF SDK 0.9

Reference

ModOptions

Global player preferences and shortcuts configurable from the NRF Hub tab of the game options.

Usage context

ModulePackageSDK source
Kotlin/Nativenimbykotlin/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.

Imports on this page
import nimby.ModOption
import nimby.BooleanOption
import nimby.IntegerOption
import nimby.OptionChoice
import nimby.ChoiceOption

ModOption

nimby · class
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

nimby · val
val id: String

Stable 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

nimby · val
val label: String

Nonempty label displayed in options, up to 256 UTF-8 bytes. Accepts tr; translating this text does not change identity.

ModOption.defaultValue

nimby · val
val defaultValue: T

Declared initial value, used when no compatible preference is saved and when resetting. Separate from the player’s current value.

ModOption.description

nimby · val
val description: String

Optional explanation, up to 1024 UTF-8 bytes; accepts tr. An empty string omits the explanation.

ModOption.value

nimby · val
val value: T

Read-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

nimby · class
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

nimby · class
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

nimby · val
val minimum: Int

Inclusive lower preference bound; a signed Kotlin Int.

IntegerOption.maximum

nimby · val
val maximum: Int

Inclusive upper preference bound; at least minimum.

OptionChoice

nimby · class
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

nimby · val
val id: String

Identifier returned by ChoiceOption.value; follows the option ID format. Do not translate it or replace it with display text.

OptionChoice.label

nimby · val
val label: String

Visible choice text, nonempty and limited to 256 UTF-8 bytes; accepts tr.

ChoiceOption

nimby · class
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

nimby · val
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.