From aa57dd9b5064a544fed858d4d64687120210cfd0 Mon Sep 17 00:00:00 2001 From: Andrew Bastien Date: Sun, 29 Oct 2023 16:44:13 -0400 Subject: [PATCH] Minor tweak to the OptionHandler.set to return objects instead of values for better integration with other systems. --- evennia/commands/default/account.py | 2 +- evennia/utils/optionhandler.py | 7 ++++--- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/evennia/commands/default/account.py b/evennia/commands/default/account.py index eb0b07495e..b24abd7807 100644 --- a/evennia/commands/default/account.py +++ b/evennia/commands/default/account.py @@ -1056,4 +1056,4 @@ class CmdStyle(COMMAND_DEFAULT_CLASS): except ValueError as e: self.msg(str(e)) return - self.msg(f"Style {self.lhs} set to {result}") + self.msg(f"Style {result.key} set to {result.display()}") diff --git a/evennia/utils/optionhandler.py b/evennia/utils/optionhandler.py index 4a3ffab2a6..3fdf8468f5 100644 --- a/evennia/utils/optionhandler.py +++ b/evennia/utils/optionhandler.py @@ -142,7 +142,7 @@ class OptionHandler: op_found = self.options.get(key) or self._load_option(key) return op_found if return_obj else op_found.value - def set(self, key, value, **kwargs): + def set(self, key, value, **kwargs) -> "BaseOption": """ Change an individual option. @@ -153,7 +153,8 @@ class OptionHandler: save function and display function and allows to customize either. Returns: - value (any): Value stored in option, after validation. + BaseOption: The matched object. Its new value can be accessed with + op.value or op.display(). """ if not key: @@ -168,7 +169,7 @@ class OptionHandler: match = match[0] op = self.get(match, return_obj=True) op.set(value, **kwargs) - return op.value + return op def all(self, return_objs=False): """