From d1f0988d80bd68d3eb7eb196b590b907407fc515 Mon Sep 17 00:00:00 2001 From: InspectorCaracal <51038201+InspectorCaracal@users.noreply.github.com> Date: Sat, 10 Feb 2024 18:07:42 -0700 Subject: [PATCH 1/3] override example crafting recipes --- evennia/contrib/game_systems/crafting/crafting.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/evennia/contrib/game_systems/crafting/crafting.py b/evennia/contrib/game_systems/crafting/crafting.py index bc1d0e140b..ccbc734b98 100644 --- a/evennia/contrib/game_systems/crafting/crafting.py +++ b/evennia/contrib/game_systems/crafting/crafting.py @@ -148,7 +148,7 @@ def _load_recipes(): if not _RECIPE_CLASSES: paths = ["evennia.contrib.game_systems.crafting.example_recipes"] if hasattr(settings, "CRAFT_RECIPE_MODULES"): - paths += make_iter(settings.CRAFT_RECIPE_MODULES) + paths = make_iter(settings.CRAFT_RECIPE_MODULES) for path in paths: for cls in callables_from_module(path).values(): if inherits_from(cls, CraftingRecipeBase): From 6d5140cebd9df3e0c679c2797485862740d8100e Mon Sep 17 00:00:00 2001 From: InspectorCaracal <51038201+InspectorCaracal@users.noreply.github.com> Date: Sun, 11 Feb 2024 21:47:59 -0700 Subject: [PATCH 2/3] don't override if setting is empty this is just so it can pass the test contrivance --- evennia/contrib/game_systems/crafting/crafting.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/evennia/contrib/game_systems/crafting/crafting.py b/evennia/contrib/game_systems/crafting/crafting.py index ccbc734b98..7dea838ab3 100644 --- a/evennia/contrib/game_systems/crafting/crafting.py +++ b/evennia/contrib/game_systems/crafting/crafting.py @@ -146,9 +146,10 @@ def _load_recipes(): global _RECIPE_CLASSES if not _RECIPE_CLASSES: - paths = ["evennia.contrib.game_systems.crafting.example_recipes"] - if hasattr(settings, "CRAFT_RECIPE_MODULES"): + if paths := getattr(settings, "CRAFT_RECIPE_MODULES", None): paths = make_iter(settings.CRAFT_RECIPE_MODULES) + else: + paths = ["evennia.contrib.game_systems.crafting.example_recipes"] for path in paths: for cls in callables_from_module(path).values(): if inherits_from(cls, CraftingRecipeBase): From 9ce3232b4c60815c45fd71e3b8aae47bac6fa236 Mon Sep 17 00:00:00 2001 From: InspectorCaracal Date: Sun, 11 Feb 2024 22:11:54 -0700 Subject: [PATCH 3/3] partial match bugfix --- evennia/contrib/game_systems/crafting/crafting.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/evennia/contrib/game_systems/crafting/crafting.py b/evennia/contrib/game_systems/crafting/crafting.py index 7dea838ab3..593f1a04b9 100644 --- a/evennia/contrib/game_systems/crafting/crafting.py +++ b/evennia/contrib/game_systems/crafting/crafting.py @@ -947,7 +947,7 @@ def craft(crafter, recipe_name, *inputs, raise_exception=False, **kwargs): # try in-match matches = [key for key in _RECIPE_CLASSES if recipe_name in key] if len(matches) == 1: - RecipeClass = matches[0] + RecipeClass = _RECIPE_CLASSES[matches[0]] if not RecipeClass: if raise_exception: