diff --git a/carbon-recipe-updates.lua b/carbon-recipe-updates.lua index 5d18323..46269d3 100644 --- a/carbon-recipe-updates.lua +++ b/carbon-recipe-updates.lua @@ -11,8 +11,8 @@ util.add_prerequisite("laser-turret", "diamond-processing") util.add_prerequisite("power-armor-mk2", "graphene") util.add_prerequisite("rocket-control-unit", "graphene") +util.add_prerequisite("electronics", "graphite-processing") if mods.Krastorio2 then - util.add_prerequisite("electronics", "graphite-processing") util.add_prerequisite("graphite-processing", "kr-crusher") end diff --git a/carbon-recipe.lua b/carbon-recipe.lua index 2375340..70fb803 100644 --- a/carbon-recipe.lua +++ b/carbon-recipe.lua @@ -76,7 +76,6 @@ data:extend({ prerequisites = {"automation"}, order = "b-b" }, - }) if mods["space-exploration"] and not mods.Krastorio2 then diff --git a/changelog.txt b/changelog.txt index 8603c9f..c731f51 100644 --- a/changelog.txt +++ b/changelog.txt @@ -1,4 +1,14 @@ --------------------------------------------------------------------------------------------------- +Version: 0.0.13 +Date: 2022-01-12 + Changes: + - Move electric drill back before electronics to avoid deadlock. +--------------------------------------------------------------------------------------------------- +Version: 0.0.12 +Date: 2022-01-08 + Changes: + - Change burner phase vanilla recipes a bit to avoid possible deadlocks +--------------------------------------------------------------------------------------------------- Version: 0.0.11 Date: 2022-01-06 Changes: diff --git a/data-final-fixes.lua b/data-final-fixes.lua index a32065d..e7a80c6 100644 --- a/data-final-fixes.lua +++ b/data-final-fixes.lua @@ -41,6 +41,22 @@ for i, furnace in pairs(util.me.furnaces) do end end +if not mods.Krastorio2 and not mods["aai-industry"] then + util.replace_ingredient("offshore-pump", "electronic-circuit", "copper-cable") + util.replace_ingredient("lab", "electronic-circuit", "copper-cable") + util.replace_ingredient("electric-mining-drill", "electronic-circuit", "copper-cable") + util.replace_ingredient("assembling-machine-1", "electronic-circuit", "copper-plate") + util.replace_ingredient("radar", "electronic-circuit", "copper-plate") + + util.add_effect("electronics", { type = "unlock-recipe", recipe = "electronic-circuit" }) + util.add_effect("electronics", { type = "unlock-recipe", recipe = "inserter" }) + util.add_effect("electronics", { type = "unlock-recipe", recipe = "long-handed-inserter" }) + util.remove_recipe_effect("automation", "long-handed-inserter") + util.set_enabled("electronic-circuit", false) + util.set_enabled("inserter", false) +end +util.set_enabled("electric-mining-drill", true) + -- Must be last util.create_list() diff --git a/data-util.lua b/data-util.lua index 9920d9e..353293e 100644 --- a/data-util.lua +++ b/data-util.lua @@ -77,14 +77,33 @@ function util.remove_prerequisite(technology_name, prerequisite) end end + -- Add an effect to a given technology function util.add_effect(technology_name, effect) local technology = data.raw.technology[technology_name] if technology then + if not technology.effects then technology.effects = {} end table.insert(technology.effects, effect) end end +-- remove recipe unlock effect from a given technology +function util.remove_recipe_effect(technology_name, recipe_name) + local technology = data.raw.technology[technology_name] + local index = -1 + if technology then + for i, effect in pairs(technology.effects) do + if effect.type == "unlock-recipe" and effect.recipe == recipe_name then + index = i + break + end + end + if index > -1 then + table.remove(technology.effects, index) + end + end +end + -- Set technology ingredients function util.set_tech_recipe(technology_name, ingredients) local technology = data.raw.technology[technology_name] @@ -93,6 +112,37 @@ function util.set_tech_recipe(technology_name, ingredients) end end +function util.set_enabled(recipe_name, enabled) + if data.raw.recipe[recipe_name] then + if data.raw.recipe[recipe_name].normal then data.raw.recipe[recipe_name].normal.enabled = enabled end + if data.raw.recipe[recipe_name].expensive then data.raw.recipe[recipe_name].expensive.enabled = enabled end + if not data.raw.recipe[recipe_name].normal then data.raw.recipe[recipe_name].enabled = enabled end + end +end + +-- Add a given quantity of ingredient to a given recipe +function util.add_or_add_to_ingredient(recipe_name, ingredient, quantity) + if me.bypass[recipe_name] then return end + if data.raw.recipe[recipe_name] and data.raw.item[ingredient] then + me.add_modified(recipe_name) + add_or_add_to_ingredient(data.raw.recipe[recipe_name], ingredient, quantity) + add_or_add_to_ingredient(data.raw.recipe[recipe_name].normal, ingredient, quantity) + add_or_add_to_ingredient(data.raw.recipe[recipe_name].expensive, ingredient, quantity) + end +end + +function add_or_add_to_ingredient(recipe, ingredient, quantity) + if recipe ~= nil and recipe.ingredients ~= nil then + for i, existing in pairs(recipe.ingredients) do + if existing[1] == ingredient or existing.name == ingredient then + add_to_ingredient(recipe, ingredient, quantity) + return + end + end + table.insert(recipe.ingredients, {ingredient, quantity}) + end +end + -- Add a given quantity of ingredient to a given recipe function util.add_ingredient(recipe_name, ingredient, quantity) if me.bypass[recipe_name] then return end @@ -115,7 +165,6 @@ function add_ingredient(recipe, ingredient, quantity) table.insert(recipe.ingredients, {ingredient, quantity}) end end - -- Add a given quantity of product to a given recipe. -- Only works for recipes with multiple products function util.add_product(recipe_name, product) @@ -338,6 +387,10 @@ end -- Remove an element of type t and name from data.raw function util.remove_raw(t, name) + if not data.raw[t] then + log(t.." not found in data.raw") + return + end if data.raw[t][name] then for i, elem in pairs(data.raw[t]) do if elem.name == name then @@ -438,7 +491,7 @@ function add_to_ingredient(recipe, it, amount) return end if ingredient[1] == it then - ingredient[2] = ingredients[2] + amount + ingredient[2] = ingredient[2] + amount return end end diff --git a/info.json b/info.json index 57dae78..6a90a12 100644 --- a/info.json +++ b/info.json @@ -1,6 +1,6 @@ { "name": "bzcarbon", - "version": "0.0.11", + "version": "0.0.13", "factorio_version": "1.1", "title": "Graphite & Diamonds", "author": "Brevven",