pub struct ModParameter {
pub id: String,
pub name: String,
pub help_text: String,
pub kind: ParameterKind,
pub enable_if: Option<String>,
pub hidden: bool,
pub validation: Option<String>,
}Expand description
One configurable setting a mod exposes to the launcher’s Mods page.
Fields§
§id: StringStable identifier, referenced from RedirectionRule::enable_if,
${param_id} interpolation placeholders, and as a key into both
this mod’s own ModConfig::configuration defaults and its entry
in crate::mods_state::ModConfigurations.
name: StringDisplay name shown in the launcher UI.
help_text: StringShown as a tooltip/help text next to the control in the launcher UI.
kind: ParameterKind§enable_if: Option<String>Optional Rhai expression that must evaluate to true for this
parameter to be editable in the launcher UI. When false (or when
evaluation fails), the parameter falls back to its default value
from ModConfig::configuration (or the type-appropriate zero
value if no default exists). Other parameters’ enable_if
expressions and rule enable_if expressions may still reference
this parameter, gating only affects the UI control, not the
parameter’s availability in the evaluation scope.
hide this parameter from the launcher’s parameter editors
entirely. Hidden parameters keep EVERY other behavior (validation,
enable_if scope, ${...} interpolation, configuration merge,
launcher-written overrides), they are just not user-facing
controls. The online-tournament mod declares its
tournament_env / tournament_difficulty /
tournament_room_id this way: the launcher sets them when the
player creates or joins a room; a user has no business editing them.
validation: Option<String>Optional name of a shared validation rule set (see
crate::validation) the launcher enforces live while the user
edits this parameter: invalid input renders an error stroke and a
warning icon whose hover carries the reason. Known tags:
player_name, room_name; unknown tags fail
ModConfig::validate. Only meaningful on text parameters.
Implementations§
Source§impl ModParameter
impl ModParameter
Sourcepub fn validate(&self) -> Result<(), String>
pub fn validate(&self) -> Result<(), String>
Structural validation, independent of any other parameter or rule,
called from ModConfig::validate so a malformed mod.json
surfaces as a clear per-mod error at load time.
§Errors
Returns an error describing the problem if this parameter’s data is
internally inconsistent (e.g. a dropdown with no choices, or a
number range with min > max).
Trait Implementations§
Source§impl Clone for ModParameter
impl Clone for ModParameter
Source§fn clone(&self) -> ModParameter
fn clone(&self) -> ModParameter
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for ModParameter
impl Debug for ModParameter
Source§impl<'de> Deserialize<'de> for ModParameter
impl<'de> Deserialize<'de> for ModParameter
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Source§impl PartialEq for ModParameter
impl PartialEq for ModParameter
Source§fn eq(&self, other: &ModParameter) -> bool
fn eq(&self, other: &ModParameter) -> bool
self and other values to be equal, and is used by ==.