diff --git a/changelog.txt b/changelog.txt index 8231d1e..b0925c5 100644 --- a/changelog.txt +++ b/changelog.txt @@ -1,4 +1,9 @@ --------------------------------------------------------------------------------------------------- +Version: 0.6.0 +Date: 2020-09-26 + Changes: + - Initial FactorioExtended Plus (FE+) compatibility +--------------------------------------------------------------------------------------------------- Version: 0.5.5 Date: 2020-09-26 Changes: diff --git a/data-util.lua b/data-util.lua index aec93b8..a9f699c 100644 --- a/data-util.lua +++ b/data-util.lua @@ -1,9 +1,32 @@ local data_util = {} +data_util.titanium_plate = "" + +if mods["FactorioExtended-Plus-Core"] then + data_util.titanium_plate = "titanium-alloy" +else + data_util.titanium_plate = "titanium-plate" +end + +-- Remove an element of type t and name from data.raw +function data_util.remove_raw(t, name) + local index = -1 + for i, elem in pairs(data.raw) do + if elem.type == t and elem.name == name then + index = i + break + end + end + if index > -1 then + table.remove(data.raw, index) + end +end + + --- Add a given quantity of titanium plates to a given recipe function data_util.add_titanium_ingredient(quantity, recipe) if recipe ~= nil and recipe.ingredients ~= nil then - table.insert(recipe.ingredients, {"titanium-plate", quantity}) + table.insert(recipe.ingredients, {data_util.titanium_plate, quantity}) end end @@ -14,12 +37,12 @@ end --- Change all occurances of steel plates to titanium plates in a given recipe function data_util.steel_to_titanium(recipe) - data_util.replace_ingredient(recipe, "steel-plate", "titanium-plate") + data_util.replace_ingredient(recipe, "steel-plate", data_util.titanium_plate) end --- Change all occurances of rare metals to titanium plates in a given recipe function data_util.rare_to_titanium(recipe) - data_util.replace_ingredient(recipe, "rare-metals", "titanium-plate") + data_util.replace_ingredient(recipe, "rare-metals", data_util.titanium_plate) end function data_util.replace_ingredient(recipe, old, new) diff --git a/info.json b/info.json index 2a35c6f..5348ed4 100644 --- a/info.json +++ b/info.json @@ -1,6 +1,6 @@ { "name": "bztitanium", - "version": "0.5.5", + "version": "0.6.0", "factorio_version": "1.0", "title": "Titanium", "author": "Brevven", @@ -11,9 +11,9 @@ "? aai-industry", "? space-exploration", "? Krastorio2", - "? Aircraft", + "? FactorioExtended-Plus-Core", "? Pre0-17-60Oil" ], - "description": "Adds titanium to the base game.\n\nTitanium is used in Low Density Structures, Flying Robot Frames and a few other places.\n\nCompatible with Krastorio 2, Space Exploration, Aircraft and other mods." + "description": "Adds titanium to the base game.\n\nTitanium is used in Low Density Structures, Flying Robot Frames and a few other places.\n\nCompatible with Krastorio 2, Space Exploration, Aircraft, FE+ and other mods." } diff --git a/locale/en/ore-refining.cfg b/locale/en/ore-refining.cfg index 6eb6979..0e3097d 100644 --- a/locale/en/ore-refining.cfg +++ b/locale/en/ore-refining.cfg @@ -7,6 +7,7 @@ titanium-ore=Titanium Ore [item-name] titanium-ore=Titanium Ore titanium-plate=Titanium Plate +titanium-alloy=__ITEM__titanium-plate__ enriched-titanium=Enriched titanium [item-description] diff --git a/titanium-ore.lua b/titanium-ore.lua index 9996501..0ec9584 100644 --- a/titanium-ore.lua +++ b/titanium-ore.lua @@ -1,7 +1,12 @@ local resource_autoplace = require('resource-autoplace'); -data:extend( -{ +local util = require("__bztitanium__.data-util"); + +if mods["FactorioExtended-Plus-Core"] then + util.remove_raw("item", "titanium-ore") +end + +data:extend({ { type = "autoplace-control", category = "resource", @@ -65,15 +70,14 @@ data:extend( } }, }, -{ - type = "item", - name = "titanium-ore", - icon_size = 32, - icon = "__bztitanium__/graphics/icons/titanium-ore.png", - subgroup = "raw-resource", - order = "t-c-a", - stack_size = (mods["Krastorio2"] and 200 or 50) -}, -} -) + { + type = "item", + name = "titanium-ore", + icon_size = 32, + icon = "__bztitanium__/graphics/icons/titanium-ore.png", + subgroup = "raw-resource", + order = "t-c-a", + stack_size = (mods["Krastorio2"] and 200 or 50) + }, +}) diff --git a/titanium-recipe.lua b/titanium-recipe.lua index 08a637f..fb6889b 100644 --- a/titanium-recipe.lua +++ b/titanium-recipe.lua @@ -1,4 +1,14 @@ -- Titanium smelting + +local util = require("__bztitanium__.data-util"); + +if mods["FactorioExtended-Plus-Core"] then + util.remove_raw("recipe", "titanium-ore") + util.remove_raw("item", "titanium-alloy") + util.remove_raw("recipe", "titanium-alloy") + util.remove_raw("technology", "titanium-processing") +end + data:extend( { { @@ -15,25 +25,25 @@ data:extend( enabled = false, energy_required = 16, ingredients = {{"titanium-ore", 10}}, - results = {{type="item", name="titanium-plate", amount_min=2, amount_max=3}}, + results = {{type="item", name= util.titanium_plate, amount_min=2, amount_max=3}}, } or { enabled = false, energy_required = 8, ingredients = {{"titanium-ore", 5}}, - result = "titanium-plate" + result = util.titanium_plate }), expensive = { enabled = false, energy_required = 16, ingredients = {{"titanium-ore", 10}}, - result = "titanium-plate" + result = util.titanium_plate } }, { type = "item", - name = "titanium-plate", + name = util.titanium_plate, icon = "__bztitanium__/graphics/icons/titanium-plate.png", icon_size = 32, subgroup = "raw-material",