initial 2.0 vanilla compat

This commit is contained in:
Brevven 2024-12-03 02:26:02 -08:00
parent 5520061fc8
commit a2163f7e0f
6 changed files with 255 additions and 328 deletions

View file

@ -1,4 +1,9 @@
---------------------------------------------------------------------------------------------------
Version: 2.0.0
Date: 2024-12-06
Features:
- Works with Factorio 2.0 vanilla
---------------------------------------------------------------------------------------------------
Version: 1.2.13
Date: 2023-12-23
Fixes:

View file

@ -305,17 +305,14 @@ function util.se_matter(params)
end
end
-- deprecated
-- Get the normal prototype for a recipe -- either .normal or the recipe itself
function util.get_normal(recipe_name)
if data.raw.recipe[recipe_name] then
recipe = data.raw.recipe[recipe_name]
if recipe.normal and recipe.normal.ingredients then
return recipe.normal
elseif recipe.ingredients then
return recipe
end
end
end
-- Set/override a technology's prerequisites
function util.set_prerequisite(technology_name, prerequisites)
@ -428,17 +425,13 @@ 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
data.raw.recipe[recipe_name].enabled = enabled
end
end
function util.set_hidden(recipe_name)
if data.raw.recipe[recipe_name] then
if data.raw.recipe[recipe_name].normal then data.raw.recipe[recipe_name].normal.hidden = true end
if data.raw.recipe[recipe_name].expensive then data.raw.recipe[recipe_name].expensive.hidden = true end
if not data.raw.recipe[recipe_name].normal then data.raw.recipe[recipe_name].hidden = true end
data.raw.recipe[recipe_name].hidden = true
end
end
@ -448,8 +441,6 @@ function util.add_or_add_to_ingredient(recipe_name, ingredient, quantity, option
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
@ -472,8 +463,6 @@ function util.add_ingredient(recipe_name, ingredient, quantity, options)
if data.raw.recipe[recipe_name] and (data.raw.item[ingredient] or is_fluid) then
me.add_modified(recipe_name)
add_ingredient(data.raw.recipe[recipe_name], ingredient, quantity, is_fluid)
add_ingredient(data.raw.recipe[recipe_name].normal, ingredient, quantity, is_fluid)
add_ingredient(data.raw.recipe[recipe_name].expensive, ingredient, quantity, is_fluid)
end
end
@ -498,8 +487,6 @@ function util.add_ingredient_raw(recipe_name, ingredient, options)
if data.raw.recipe[recipe_name] and data.raw.item[ingredient.name] then
me.add_modified(recipe_name)
add_ingredient_raw(data.raw.recipe[recipe_name], ingredient)
add_ingredient_raw(data.raw.recipe[recipe_name].normal, ingredient)
add_ingredient_raw(data.raw.recipe[recipe_name].expensive, ingredient)
end
end
@ -520,8 +507,6 @@ function util.set_ingredient(recipe_name, ingredient, quantity, options)
if data.raw.recipe[recipe_name] and data.raw.item[ingredient] then
me.add_modified(recipe_name)
set_ingredient(data.raw.recipe[recipe_name], ingredient, quantity)
set_ingredient(data.raw.recipe[recipe_name].normal, ingredient, quantity)
set_ingredient(data.raw.recipe[recipe_name].expensive, ingredient, quantity)
end
end
@ -546,15 +531,12 @@ function util.add_product(recipe_name, product, options)
(data.raw.item[product.name] or data.raw.fluid[product.name]
) then
add_product(data.raw.recipe[recipe_name], product)
add_product(data.raw.recipe[recipe_name].normal, product)
add_product(data.raw.recipe[recipe_name].expensive, product)
end
end
function add_product(recipe, product)
if recipe ~= nil then
if product.name and data.raw[product.type][product.name] then
if not recipe.normal then
if recipe.results == nil then
recipe.results = {{recipe.result, recipe.result_count and recipe.result_count or 1}}
end
@ -564,17 +546,12 @@ function add_product(recipe, product)
end
end
end
end
-- Get the amount of the ingredient, will check base/normal not expensive
-- Get the amount of the ingredient
function util.get_ingredient_amount(recipe_name, ingredient_name)
local recipe = data.raw.recipe[recipe_name]
if recipe then
if recipe.normal and recipe.normal.ingredients then
for i, ingredient in pairs(recipe.normal.ingredients) do
if ingredient.name == ingredient_name then return ingredient.amount end
end
elseif recipe.ingredients then
if recipe.ingredients then
for i, ingredient in pairs(recipe.ingredients) do
if ingredient.name == ingredient_name then return ingredient.amount end
end
@ -584,25 +561,17 @@ function util.get_ingredient_amount(recipe_name, ingredient_name)
return 0
end
-- Get the amount of the result, will check base/normal not expensive
-- Get the amount of the result
function util.get_amount(recipe_name, product)
if not product then product = recipe_name end
local recipe = data.raw.recipe[recipe_name]
if recipe then
if recipe.normal and recipe.normal.results then
for i, result in pairs(recipe.normal.results) do
if result.name == product then return result.amount end
end
elseif recipe.normal and recipe.normal.result_count then
return recipe.normal.result_count
elseif recipe.results then
if recipe.results then
for i, result in pairs(recipe.results) do
if result.name == product then return result.amount end
end
elseif recipe.result_count then
return recipe.result_count
end
return 1
return 0
end
return 0
end
@ -612,9 +581,7 @@ function util.get_result_count(recipe_name, product)
if not product then product = recipe_name end
local recipe = data.raw.recipe[recipe_name]
if recipe then
if recipe.normal and recipe.normal.results then
return #(recipe.normal.results)
elseif recipe.results then
if recipe.results then
return #(recipe.results)
end
return 1
@ -629,8 +596,6 @@ function util.replace_ingredient(recipe_name, old, new, amount, multiply, option
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, amount, multiply)
replace_ingredient(data.raw.recipe[recipe_name].normal, old, new, amount, multiply)
replace_ingredient(data.raw.recipe[recipe_name].expensive, old, new, amount, multiply)
end
end
@ -662,8 +627,6 @@ function util.remove_ingredient(recipe_name, old, options)
if data.raw.recipe[recipe_name] then
me.add_modified(recipe_name)
remove_ingredient(data.raw.recipe[recipe_name], old)
remove_ingredient(data.raw.recipe[recipe_name].normal, old)
remove_ingredient(data.raw.recipe[recipe_name].expensive, old)
end
end
@ -689,8 +652,6 @@ function util.replace_some_product(recipe_name, old, old_amount, new, new_amount
if data.raw.recipe[recipe_name] and (data.raw.item[new] or is_fluid) then
me.add_modified(recipe_name)
replace_some_product(data.raw.recipe[recipe_name], old, old_amount, new, new_amount, is_fluid)
replace_some_product(data.raw.recipe[recipe_name].normal, old, old_amount, new, new_amount, is_fluid)
replace_some_product(data.raw.recipe[recipe_name].expensive, old, old_amount, new, new_amount, is_fluid)
end
end
@ -720,8 +681,6 @@ function util.replace_some_ingredient(recipe_name, old, old_amount, new, new_amo
if data.raw.recipe[recipe_name] and (data.raw.item[new] or is_fluid) then
me.add_modified(recipe_name)
replace_some_ingredient(data.raw.recipe[recipe_name], old, old_amount, new, new_amount, is_fluid)
replace_some_ingredient(data.raw.recipe[recipe_name].normal, old, old_amount, new, new_amount, is_fluid)
replace_some_ingredient(data.raw.recipe[recipe_name].expensive, old, old_amount, new, new_amount, is_fluid)
end
end
@ -747,8 +706,6 @@ function util.set_product_amount(recipe_name, product, amount, options)
me.add_modified(recipe_name)
if data.raw.recipe[recipe_name] then
set_product_amount(data.raw.recipe[recipe_name], product, amount)
set_product_amount(data.raw.recipe[recipe_name].normal, product, amount)
set_product_amount(data.raw.recipe[recipe_name].expensive, product, amount)
end
end
@ -784,8 +741,6 @@ function util.multiply_recipe(recipe_name, multiple, options)
me.add_modified(recipe_name)
if data.raw.recipe[recipe_name] then
multiply_recipe(data.raw.recipe[recipe_name], multiple)
multiply_recipe(data.raw.recipe[recipe_name].normal, multiple)
multiply_recipe(data.raw.recipe[recipe_name].expensive, multiple)
end
end
@ -831,9 +786,8 @@ end
-- Returns true if a recipe has an ingredient
function util.has_ingredient(recipe_name, ingredient)
return data.raw.recipe[recipe_name] and (
has_ingredient(data.raw.recipe[recipe_name], ingredient) or
has_ingredient(data.raw.recipe[recipe_name].normal, ingredient))
return data.raw.recipe[recipe_name] and
has_ingredient(data.raw.recipe[recipe_name], ingredient)
end
function has_ingredient(recipe, ingredient)
@ -853,8 +807,6 @@ function util.remove_product(recipe_name, old, options)
me.add_modified(recipe_name)
if data.raw.recipe[recipe_name] then
remove_product(data.raw.recipe[recipe_name], old)
remove_product(data.raw.recipe[recipe_name].normal, old)
remove_product(data.raw.recipe[recipe_name].expensive, old)
end
end
@ -877,8 +829,6 @@ function util.set_main_product(recipe_name, product, options)
if not should_force(options) and bypass(recipe_name) then return end
if data.raw.recipe[recipe_name] then
set_main_product(data.raw.recipe[recipe_name], product)
set_main_product(data.raw.recipe[recipe_name].normal, product)
set_main_product(data.raw.recipe[recipe_name].expensive, product)
end
end
@ -893,8 +843,6 @@ function util.replace_product(recipe_name, old, new, options)
if not should_force(options) and bypass(recipe_name) then return end
if data.raw.recipe[recipe_name] then
replace_product(data.raw.recipe[recipe_name], old, new, options)
replace_product(data.raw.recipe[recipe_name].normal, old, new, options)
replace_product(data.raw.recipe[recipe_name].expensive, old, new, options)
end
end
@ -937,8 +885,6 @@ function util.set_recipe_time(recipe_name, time, options)
me.add_modified(recipe_name)
if data.raw.recipe[recipe_name] then
set_recipe_time(data.raw.recipe[recipe_name], time)
set_recipe_time(data.raw.recipe[recipe_name].normal, time)
set_recipe_time(data.raw.recipe[recipe_name].expensive, time)
end
end
@ -956,8 +902,6 @@ function util.multiply_time(recipe_name, factor, options)
me.add_modified(recipe_name)
if data.raw.recipe[recipe_name] then
multiply_time(data.raw.recipe[recipe_name], factor)
multiply_time(data.raw.recipe[recipe_name].normal, factor)
multiply_time(data.raw.recipe[recipe_name].expensive, factor)
end
end
@ -975,8 +919,6 @@ function util.add_time(recipe_name, amount, options)
me.add_modified(recipe_name)
if data.raw.recipe[recipe_name] then
add_time(data.raw.recipe[recipe_name], amount)
add_time(data.raw.recipe[recipe_name].normal, amount)
add_time(data.raw.recipe[recipe_name].expensive, amount)
end
end
@ -1037,13 +979,6 @@ function util.add_icon(recipe_name, icon, options)
icon_size=data.raw.item[data.raw.recipe[recipe_name].result].icon_size,
icon_mipmaps=data.raw.item[data.raw.recipe[recipe_name].result].icon_mipmaps,
}}
elseif data.raw.recipe[recipe_name].normal and
data.raw.item[data.raw.recipe[recipe_name].normal.result] then
data.raw.recipe[recipe_name].icons = {{
icon=data.raw.item[data.raw.recipe[recipe_name].normal.result].icon,
icon_size=data.raw.item[data.raw.recipe[recipe_name].normal.result].icon_size,
icon_mipmaps=data.raw.item[data.raw.recipe[recipe_name].normal.result].icon_mipmaps,
}}
end
data.raw.recipe[recipe_name].icon = nil
data.raw.recipe[recipe_name].icon_size = nil
@ -1106,8 +1041,6 @@ function util.add_to_ingredient(recipe, ingredient, amount, options)
if not should_force(options) and bypass(recipe_name) then return end
if data.raw.recipe[recipe] then
add_to_ingredient(data.raw.recipe[recipe], ingredient, amount)
add_to_ingredient(data.raw.recipe[recipe].normal, ingredient, amount)
add_to_ingredient(data.raw.recipe[recipe].expensive, ingredient, amount)
end
end
@ -1130,8 +1063,6 @@ function util.add_to_product(recipe_name, product, amount, options)
if not should_force(options) and bypass(recipe_name) then return end
if data.raw.recipe[recipe_name] then
add_to_product(data.raw.recipe[recipe_name], product, amount)
add_to_product(data.raw.recipe[recipe_name].normal, product, amount)
add_to_product(data.raw.recipe[recipe_name].expensive, product, amount)
end
end

View file

@ -1,7 +1,7 @@
{
"name": "bztitanium",
"version": "1.2.13",
"factorio_version": "1.1",
"version": "2.0.0",
"factorio_version": "2.0",
"title": "Titanium",
"author": "Brevven",
"contact": "",

View file

@ -5,6 +5,8 @@ local util = require("__bztitanium__.data-util");
if mods["FactorioExtended-Plus-Core"] then
util.remove_raw("item", "titanium-ore")
end
data.raw.planet.nauvis.map_gen_settings.autoplace_controls["titanium-ore"] = {}
data.raw.planet.nauvis.map_gen_settings.autoplace_settings.entity.settings["titanium-ore"] = {}
if (not mods["pyrawores"]) then
data:extend({
@ -15,10 +17,10 @@ data:extend({
richness = true,
order = "b-e"
},
{
type = "noise-layer",
name = "titanium-ore"
},
--{
-- type = "noise-layer",
-- name = "titanium-ore"
--},
{
type = "resource",
icon_size = 64, icon_mipmaps = 3,

View file

@ -2,31 +2,32 @@
local util = require("data-util");
for i, recipe in pairs(util.me.recipes) do
if data.raw.recipe[recipe] then
for j, module in pairs(data.raw.module) do
if module.effect then
for effect_name, effect in pairs(module.effect) do
if effect_name == "productivity" and effect.bonus > 0 and module.limitation and #module.limitation > 0 then
table.insert(module.limitation, recipe)
end
end
end
end
end
end
-- FE+ allows modules for Titanium ore, we can't do that.
if mods["FactorioExtended-Plus-Core"] then
for j, module in pairs(data.raw.module) do
if module.limitation and #module.limitation > 0 then
for i=1,#module.limitation,1 do
if module.limitation[i] == "titanium-ore" then
table.remove(module.limitation, i)
break
end
end
end
end
end
-- for i, recipe in pairs(util.me.recipes) do
-- if data.raw.recipe[recipe] then
-- for j, module in pairs(data.raw.module) do
-- if module.effect then
-- log(serpent.block(module))
-- for effect_name, effect in pairs(module.effect) do
-- if effect_name == "productivity" and module.effect.productivity > 0 then
-- table.insert(module.limitation, recipe)
-- end
-- end
-- end
-- end
-- end
-- end
--
--
-- -- FE+ allows modules for Titanium ore, we can't do that.
-- if mods["FactorioExtended-Plus-Core"] then
-- for j, module in pairs(data.raw.module) do
-- if module.limitation and #module.limitation > 0 then
-- for i=1,#module.limitation,1 do
-- if module.limitation[i] == "titanium-ore" then
-- table.remove(module.limitation, i)
-- break
-- end
-- end
-- end
-- end
-- end

View file

@ -31,28 +31,16 @@ data:extend({
{ icon = "__bztitanium__/graphics/icons/titanium-plate.png", icon_size = 64, icon_mipmaps = 3,},
{ icon = "__bztitanium__/graphics/icons/titanium-ore.png", icon_size = 64, icon_mipmaps = 3, scale=0.25, shift= {-8, -8}},
} or nil),
normal = (mods["Krastorio2"] and
{
enabled = false,
energy_required = 16,
ingredients = {{"titanium-ore", 10}},
results =
mods["crafting-efficiency-2"] and {{type="item", name= util.me.titanium_plate, amount=3, probability=5/6}} or
{{type="item", name= util.me.titanium_plate, amount_min=2, amount_max=3}} ,
} or
{
enabled = false,
energy_required = 8,
ingredients = {{"titanium-ore", 5}},
result = util.me.titanium_plate
}),
expensive =
{
enabled = false,
energy_required = 16,
ingredients = {{"titanium-ore", 10}},
result = util.me.titanium_plate
}
energy_required = mods.Krastorio2 and 16 or 8,
ingredients = {util.item("titanium-ore", mods.Krastorio2 and 10 or 5)},
results = {mods.Krastorio2 and {type="item", name= util.me.titanium_plate, amount_min=2, amount_max=3} or util.item(util.me.titanium_plate)},
-- expensive =
-- {
-- energy_required = 16,
-- ingredients = {{"titanium-ore", 10}},
-- result = util.me.titanium_plate
-- }
},
{
type = "item",
@ -97,27 +85,27 @@ data:extend({
prerequisites = {"lubricant"},
order = "b-b"
},
mods["TheBigFurnace"] and {
type = "recipe",
name = "big-titanium-plate",
category = "big-smelting",
order = "d[titanium-plate]",
normal =
{
enabled = false,
energy_required = 8.75,
ingredients = {{"titanium-ore", 50}},
result = util.me.titanium_plate,
result_count = 10,
},
expensive =
{
enabled = false,
energy_required = 16,
ingredients = {{"titanium-ore", 100}},
result = util.me.titanium_plate,
result_count = 10,
}
} or nil,
-- mods["TheBigFurnace"] and {
-- type = "recipe",
-- name = "big-titanium-plate",
-- category = "big-smelting",
-- order = "d[titanium-plate]",
-- normal =
-- {
-- enabled = false,
-- energy_required = 8.75,
-- ingredients = {{"titanium-ore", 50}},
-- result = util.me.titanium_plate,
-- result_count = 10,
-- },
-- expensive =
-- {
-- enabled = false,
-- energy_required = 16,
-- ingredients = {{"titanium-ore", 100}},
-- result = util.me.titanium_plate,
-- result_count = 10,
-- }
-- } or nil,
})
end