From a324c9781541563bde9885c4d7715b89b5e96f63 Mon Sep 17 00:00:00 2001 From: Fabian Dill Date: Fri, 11 Apr 2025 20:52:20 +0200 Subject: [PATCH] Factorio: fix FloatRanges writing effectively nil into the mod (#4846) --- worlds/factorio/Options.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/worlds/factorio/Options.py b/worlds/factorio/Options.py index 481ed009..12fc90c1 100644 --- a/worlds/factorio/Options.py +++ b/worlds/factorio/Options.py @@ -8,17 +8,20 @@ from schema import Schema, Optional, And, Or, SchemaError from Options import Choice, OptionDict, OptionSet, DefaultOnToggle, Range, DeathLink, Toggle, \ StartInventoryPool, PerGameCommonOptions, OptionGroup + # schema helpers class FloatRange: def __init__(self, low, high): self._low = low self._high = high - def validate(self, value): + def validate(self, value) -> float: if not isinstance(value, (float, int)): raise SchemaError(f"should be instance of float or int, but was {value!r}") if not self._low <= value <= self._high: raise SchemaError(f"{value} is not between {self._low} and {self._high}") + return float(value) + LuaBool = Or(bool, And(int, lambda n: n in (0, 1)))