From e8b6a1b0aca41d607db908bf03d4c2dab601d367 Mon Sep 17 00:00:00 2001 From: Brevven Date: Sat, 9 Jul 2022 18:23:46 -0700 Subject: [PATCH] double furnace --- changelog.txt | 6 ++++++ data-final-fixes.lua | 6 +++++- data-util.lua | 28 +++++++++++++++------------- info.json | 2 +- tungsten-recipe.lua | 20 ++++++++++++++++++++ 5 files changed, 47 insertions(+), 15 deletions(-) diff --git a/changelog.txt b/changelog.txt index ada9e56..4dd4cb3 100644 --- a/changelog.txt +++ b/changelog.txt @@ -1,4 +1,10 @@ --------------------------------------------------------------------------------------------------- +Version: 0.6.5 +Date: 2021-07-10 + Changes: + - Support Double Furnace mod + - ru locale updates thanks to Pergamum663 +--------------------------------------------------------------------------------------------------- Version: 0.6.4 Date: 2021-07-03 Fixes: diff --git a/data-final-fixes.lua b/data-final-fixes.lua index 8221e17..7ca2052 100644 --- a/data-final-fixes.lua +++ b/data-final-fixes.lua @@ -10,7 +10,11 @@ local util = require("__bztungsten__.data-util"); -- Only burners can make tungsten carbide in vanilla for i, entity in pairs(data.raw.furnace) do if entity.energy_source.type == "burner" then - table.insert(entity.crafting_categories,"smelting-carbon") + if entity.name == "double-steel-furnace" then + table.insert(entity.crafting_categories,"double-smelting-carbon") + else + table.insert(entity.crafting_categories,"smelting-carbon") + end end end diff --git a/data-util.lua b/data-util.lua index 0994028..37f09b8 100644 --- a/data-util.lua +++ b/data-util.lua @@ -183,7 +183,6 @@ function add_ingredient(recipe, ingredient, quantity, is_fluid) 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 - log("Not adding "..ingredient.." -- duplicate") return end end @@ -271,27 +270,32 @@ function add_product(recipe, product) end -- Replace one ingredient with another in a recipe -function util.replace_ingredient(recipe_name, old, new) +function util.replace_ingredient(recipe_name, old, new, amount) if me.bypass[recipe_name] then return end if data.raw.recipe[recipe_name] and (data.raw.item[new] or data.raw.fluid[new]) then me.add_modified(recipe_name) - replace_ingredient(data.raw.recipe[recipe_name], old, new) - replace_ingredient(data.raw.recipe[recipe_name].normal, old, new) - replace_ingredient(data.raw.recipe[recipe_name].expensive, old, new) + replace_ingredient(data.raw.recipe[recipe_name], old, new, amount) + replace_ingredient(data.raw.recipe[recipe_name].normal, old, new, amount) + replace_ingredient(data.raw.recipe[recipe_name].expensive, old, new, amount) end end -function replace_ingredient(recipe, old, new) +function replace_ingredient(recipe, old, new, amount) if recipe ~= nil and recipe.ingredients ~= nil then for i, existing in pairs(recipe.ingredients) do if existing[1] == new or existing.name == new then - log("Not adding "..new.." -- duplicate") return end end for i, ingredient in pairs(recipe.ingredients) do - if ingredient.name == old then ingredient.name = new end - if ingredient[1] == old then ingredient[1] = new end + if ingredient.name == old then + ingredient.name = new + if amount then ingredient.amount = amount end + end + if ingredient[1] == old then + ingredient[1] = new + if amount then ingredient[2] = amount end + end end end end @@ -338,7 +342,6 @@ function replace_some_ingredient(recipe, old, old_amount, new, new_amount, is_fl if recipe ~= nil and recipe.ingredients ~= nil then for i, existing in pairs(recipe.ingredients) do if existing[1] == new or existing.name == new then - log("Not adding "..new.." -- duplicate") return end end @@ -551,7 +554,7 @@ end -- Set recipe category function util.set_category(recipe_name, category) if me.bypass[recipe_name] then return end - if data.raw.recipe[recipe_name] then + if data.raw.recipe[recipe_name] and data.raw["recipe-category"][category] then me.add_modified(recipe_name) data.raw.recipe[recipe_name].category = category end @@ -601,10 +604,9 @@ end -- Add crafting category to an entity function util.add_crafting_category(entity_type, entity, category) - if data.raw[entity_type][entity] then + if data.raw[entity_type][entity] and data.raw["recipe-category"][category] then for i, existing in pairs(data.raw[entity_type][entity].crafting_categories) do if existing == category then - log(entity.." not adding "..category.." -- duplicate") return end end diff --git a/info.json b/info.json index 480755d..b54e195 100644 --- a/info.json +++ b/info.json @@ -1,5 +1,5 @@ { "name": "bztungsten", - "version": "0.6.4", + "version": "0.6.5", "factorio_version": "1.1", "title": "Tungsten", "author": "Brevven", diff --git a/tungsten-recipe.lua b/tungsten-recipe.lua index 35a7eb4..11dcc8a 100644 --- a/tungsten-recipe.lua +++ b/tungsten-recipe.lua @@ -206,3 +206,23 @@ data:extend({ } }) + +if mods.DoubleFurnace then +data:extend({ + { type = "recipe-category", name = "double-smelting-carbon"}, +}) + +data:extend({ + { + type = "recipe", + name = "double-tungsten", + category = "double-smelting-carbon", + enabled = false, + energy_required = 32/3, + ingredients = {{"tungsten-ore", 5}}, + results = {{"tungsten-carbide", 1}}, + } +}) +util.add_effect(util.me.tungsten_processing, {type = "unlock-recipe", recipe = "double-tungsten"}) +end +