Merge branch 'craftguide-clear_craft' of dekunuts/MeseCraft into unstable

master
MeseCraft 2022-08-14 13:25:07 +00:00 committed by Gogs
commit 0e5af25afe
1 changed files with 22 additions and 7 deletions

View File

@ -1351,15 +1351,30 @@ end
local old_clear_craft = core.clear_craft
core.clear_craft = function(def)
old_clear_craft(def)
local craft_removed = old_clear_craft(def)
if true_str(def) then
def = match(def, "%S*")
recipes_cache[def] = nil
fuel_cache[def] = nil
if craft_removed then
if true_str(def) then
def = match(def, "%S*")
recipes_cache[def] = nil
fuel_cache[def] = nil
elseif is_table(def) then
return -- TODO
elseif is_table(def) then
if def.type == "toolrepair" then
return
end
for item_name, item_recipes in pairs(recipes_cache) do
for recipe_index, recipe in pairs(item_recipes) do
for ingredient_index, ingredient in pairs(recipe.items) do
if (recipe.type == def.type) and (ingredient == def.recipe) then
table.remove(recipes_cache[item_name], recipe_index)
return
end
end
end
end
end
end
end