fe+ compatibility

This commit is contained in:
Brevven 2020-09-27 16:41:39 -07:00
parent c845feda57
commit f4800d840d
6 changed files with 66 additions and 23 deletions

View file

@ -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:

View file

@ -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)

View file

@ -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."
}

View file

@ -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]

View file

@ -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)
},
})

View file

@ -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",