diff --git a/README.md b/README.md index a4d58b1..ef2b782 100644 --- a/README.md +++ b/README.md @@ -72,7 +72,7 @@ Dependencies: Minetest Game or MineClone. * Test everything in MTG, MCL2, and MCLA (and 5.7) * Everything breaks properly in MTG * Fix Tmcl_banners thing -* Fix Technic Beta +* Check for MCL coral groups ### v6.0 (The Compatibility Update) diff --git a/exchangeclone/register_energy.lua b/exchangeclone/register_energy.lua index c574bbe..58644ef 100644 --- a/exchangeclone/register_energy.lua +++ b/exchangeclone/register_energy.lua @@ -1,6 +1,7 @@ -- Calculates the cheapest recipe given an itemstring. -- Would probably benefit from another function, since there's quite a bit -- of duplicate code. + local function get_cheapest_recipe(itemstring, log) itemstring = ItemStack(itemstring):get_name() local recipes = exchangeclone.recipes[itemstring] @@ -101,7 +102,7 @@ local function get_cheapest_recipe(itemstring, log) cheapest = {total_cost, recipe} end end - if log then minetest.log(dump({ + if log then minetest.log("action", dump({ recipe = recipe, ingredient_cost = ingredient_cost, output_count = output_count @@ -144,18 +145,6 @@ end local auto = {} --- Register group energy values -local groupnames = {} -for index, group in ipairs(exchangeclone.group_values) do - groupnames[#groupnames + 1] = group[1] --Get list of group names -end -local grouped_items = exchangeclone.get_group_items(groupnames, true, true) -for index, group in ipairs(exchangeclone.group_values) do - for i, item in pairs(grouped_items[group[1]]) do - set_item_energy(item, group[2]) - end -end - -- Handle stonecutter recipes and decaychains in Mineclonia if exchangeclone.mcla then exchangeclone.register_craft_type("stonecutting", "cooking") @@ -338,7 +327,33 @@ end for itemstring, recipes in pairs(exchangeclone.recipes) do local new_name = ItemStack(itemstring):get_name() if new_name and new_name ~= "" and new_name ~= itemstring then - exchangeclone.recipes[new_name] = recipes + exchangeclone.recipes[new_name] = exchangeclone.recipes[new_name] or {} + for _, recipe in pairs(recipes) do + table.insert(exchangeclone.recipes[new_name], recipe) + end + end +end + + + + + +-- Up to this point, no energy values have been registered. +-- Now, they will be. + + + + + +-- Register group energy values +local groupnames = {} +for index, group in ipairs(exchangeclone.group_values) do + groupnames[#groupnames + 1] = group[1] --Get list of group names +end +local grouped_items = exchangeclone.get_group_items(groupnames, true, true) +for index, group in ipairs(exchangeclone.group_values) do + for i, item in pairs(grouped_items[group[1]]) do + set_item_energy(item, group[2]) end end diff --git a/zzzz_exchangeclone_init/lib.lua b/zzzz_exchangeclone_init/lib.lua index 3f7da9c..ee0abbf 100644 --- a/zzzz_exchangeclone_init/lib.lua +++ b/zzzz_exchangeclone_init/lib.lua @@ -775,14 +775,15 @@ function exchangeclone.register_craft(data) local itemstring = ItemStack(data.output):get_name() exchangeclone.recipes[itemstring] = exchangeclone.recipes[itemstring] or {} table.insert(exchangeclone.recipes[itemstring], table.copy(data)) + -- Should reversed recipe be registered too? if data.type then local type_data = exchangeclone.craft_types[data.type] if type_data.type == "cooking" and type_data.reverse then local flipped_data = table.copy(data) flipped_data.output, flipped_data.recipe = flipped_data.recipe, flipped_data.output - local itemstring = ItemStack(flipped_data.output):get_name() - exchangeclone.recipes[itemstring] = exchangeclone.recipes[itemstring] or {} - table.insert(exchangeclone.recipes[itemstring], table.copy(flipped_data)) + local flipped_output = ItemStack(flipped_data.output):get_name() + exchangeclone.recipes[flipped_output] = exchangeclone.recipes[flipped_output] or {} + table.insert(exchangeclone.recipes[flipped_output], table.copy(flipped_data)) end end end