Merge pull request #3425 from InspectorCaracal/patch-10

Override example crafting recipes
This commit is contained in:
Griatch 2024-02-24 09:54:25 +01:00 committed by GitHub
commit 772d4c21b5
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -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"):
paths += make_iter(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):
@ -946,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: