modernize *-nanotube recipes

This commit is contained in:
Brevven 2022-09-25 00:07:09 -07:00
parent 662cc8bf98
commit 501e659f8b
9 changed files with 74 additions and 173 deletions

View file

@ -1,72 +1,11 @@
local util = require("data-util");
local futil = require("util")
local util = require("data-util")
local cutil = require("carbon-util")
if mods.Krastorio2 then
if util.me.use_fullerenes() then
-- Add extra nanotube recipes.
-- This could be moved to data-updates in future if necessary
data:extend({
{
type = "recipe",
name = "imersium-plate-nanotubes",
icons = {
{ icon = data.raw.item["imersium-plate"].icon, icon_size = data.raw.item["imersium-plate"].icon_size},
{ icon = "__bzcarbon__/graphics/icons/nanotube.png", icon_size = 128, scale=0.125, shift= {-8, -8}},
},
category = "smelting",
subgroup = "raw-material",
order = "e00-a2[imersium-plate]",
enabled = false,
energy_required = 32,
ingredients = {
{"nanotubes", 6},
table.unpack(futil.table.deepcopy(data.raw.recipe["imersium-plate"].ingredients)),
},
result = "imersium-plate",
result_count = 6,
},
{
type = "recipe",
name = "imersium-beam-nanotubes",
icons = {
{ icon = data.raw.item["imersium-beam"].icon, icon_size = data.raw.item["imersium-beam"].icon_size},
{ icon = "__bzcarbon__/graphics/icons/nanotube.png", icon_size = 128, scale=0.125, shift= {-8, -8}},
},
category = "smelting-crafting",
subgroup = "smelting-crafting",
hide_from_player_crafting = true,
order = data.raw.item["imersium-beam"].order.."z",
enabled = false,
energy_required = 12,
ingredients = {
{"nanotubes", 4},
table.unpack(futil.table.deepcopy(data.raw.recipe["kr-s-c-imersium-beam"].ingredients)),
},
result = "imersium-beam",
result_count = 2,
},
{
type = "recipe",
name = "imersium-gear-wheel-nanotubes",
icons = {
{ icon = data.raw.item["imersium-gear-wheel"].icon, icon_size = data.raw.item["imersium-gear-wheel"].icon_size},
{ icon = "__bzcarbon__/graphics/icons/nanotube.png", icon_size = 128, scale=0.125, shift= {-8, -8}},
},
category = "smelting-crafting",
subgroup = "smelting-crafting",
hide_from_player_crafting = true,
order = data.raw.item["imersium-gear-wheel"].order.."z",
enabled = false,
energy_required = 12,
ingredients = {
{"nanotubes", 2},
table.unpack(futil.table.deepcopy(data.raw.recipe["kr-s-c-imersium-gear-wheel"].ingredients)),
},
result = "imersium-gear-wheel",
result_count = 2,
},
})
util.add_unlock("nanotubes", "imersium-plate-nanotubes")
util.add_unlock("nanotubes", "imersium-beam-nanotubes")
util.add_unlock("nanotubes", "imersium-gear-wheel-nanotubes")
-- Add extra nanotube recipes.
-- This could be moved to data-updates in future if necessary
cutil.nanotube_recipe("imersium-plate")
cutil.nanotube_recipe("kr-s-c-imersium-beam", "imersium-beam")
cutil.nanotube_recipe("kr-s-c-imersium-gear-wheel", "imersium-gear-wheel")
end
end

View file

@ -1,58 +1,13 @@
local util = require("data-util");
local futil = require("util")
local cutil = require("carbon-util")
if mods["space-exploration"] then
-- core mining balancing graphite at full, diamond removed
util.remove_product("se-core-fragment-omni", "rough-diamond")
if util.me.use_fullerenes() then
-- Add an extra nanotube aeroframe scaffold recipe.
-- This could be moved to data-updates in future if necessary
data:extend({
{
type = "recipe",
name = "aeroframe-scaffold-nanotubes",
icons = {
{ icon = data.raw.item["se-aeroframe-scaffold"].icon, icon_size = data.raw.item["se-aeroframe-scaffold"].icon_size},
{ icon = "__bzcarbon__/graphics/icons/nanotube.png", icon_size = 128, scale=0.125, shift= {-8, -8}},
},
category = "crafting",
order = data.raw.item["se-aeroframe-scaffold"].order.."z",
enabled = false,
energy_required = 2,
ingredients = {
{"nanotubes", 2},
table.unpack(futil.table.deepcopy(data.raw.recipe["se-aeroframe-scaffold"].ingredients)),
},
result = "se-aeroframe-scaffold",
result_count = 2,
},
})
util.add_unlock("se-aeroframe-scaffold", "aeroframe-scaffold-nanotubes")
data:extend({
{
type = "recipe",
name = "nanomaterial-nanotubes",
icons = {
{ icon = data.raw.item["se-nanomaterial"].icon, icon_size = data.raw.item["se-nanomaterial"].icon_size},
{ icon = "__bzcarbon__/graphics/icons/nanotube.png", icon_size = 128, scale=0.125, shift= {-8, -8}},
},
category = data.raw.recipe["se-nanomaterial"].category,
order = data.raw.item["se-nanomaterial"].order.."z",
subgroup = data.raw.item["se-nanomaterial"].subgroup,
enabled = false,
energy_required = data.raw.recipe["se-nanomaterial"].energy_required,
ingredients = {
{"nanotubes", 2},
table.unpack(futil.table.deepcopy(data.raw.recipe["se-nanomaterial"].ingredients)),
},
results = {
table.unpack(futil.table.deepcopy(data.raw.recipe["se-nanomaterial"].results)),
}
}
})
util.add_to_product("nanomaterial-nanotubes", "se-nanomaterial", 16)
util.add_unlock("se-nanomaterial", "nanomaterial-nanotubes")
cutil.nanotube_recipe("se-aeroframe-scaffold", "se-aeroframe-scaffold", "se-aeroframe-scaffold")
local nm_name = cutil.nanotube_recipe("se-nanomaterial", "se-nanomaterial", "se-nanomaterial")
util.set_ingredient(nm_name, "nanotubes", 2)
end
end

View file

@ -11,17 +11,19 @@ recipes = {
"fullerenes",
"nanotubes",
"low-density-structure-nanotubes",
"imersium-plate-nanotubes",
"imersium-beam-nanotubes",
"imersium-gear-wheel-nanotubes",
"aeroframe-scaffold-nanotubes",
"nanomaterial-nanotubes",
"diamond-synthesis-vulcanite",
-- NOTE: Carbon black recipes do not allow prod modules
}
-- Add all *-nanotubes recipes that exist
local ending = "-nanotubes"
for i, recipe in pairs(data.raw.recipe) do
if recipe.name:sub(-#ending) == ending then
table.insert(recipes, recipe.name)
end
end
for i, recipe in pairs(recipes) do
if data.raw.recipe[recipe] then
for j, module in pairs(data.raw.module) do

29
carbon-util.lua Normal file
View file

@ -0,0 +1,29 @@
local futil = require("util")
local util = require("data-util");
local cutil = {}
function cutil.nanotube_recipe(recipe_name, item_name, tech)
if not tech then tech = "nanotubes" end
if not item_name then item_name = recipe_name end
if not data.raw.recipe[recipe_name] or not data.raw.item[item_name] then return end
-- local normal = get_normal(recipe_name)
local new_recipe = futil.table.deepcopy(data.raw.recipe[recipe_name])
new_recipe.name = recipe_name.."-nanotubes"
new_recipe.icons = {
{ icon = data.raw.item[item_name].icon, icon_size = data.raw.item[item_name].icon_size},
{ icon = "__bzcarbon__/graphics/icons/nanotube.png", icon_size = 128, scale=0.125, shift= {-8, -8}},
}
new_recipe.icon = nil
new_recipe.icon_size = nil
new_recipe.icon_mipmaps = nil
data:extend({new_recipe})
local amt = 2 * util.get_amount(recipe_name, item_name)
util.add_ingredient(new_recipe.name, "nanotubes", amt, {force=true})
util.set_product_amount(new_recipe.name, item_name, amt, {force=true})
util.add_unlock(tech, new_recipe.name)
return new_recipe.name
end
return cutil

View file

@ -1,8 +1,10 @@
---------------------------------------------------------------------------------------------------
Version: 0.4.7
Date: 2022-09-25
Changes:
- Updated some nanotube recipes to more closely mirror their counterparts in all mod loadouts.
Fixes:
- Attempt to fix issue with K2, S3, Omni mods, 248k.
- Attempt to fix issue with K2, S3, Omni mods, 248k, when used with nanotubes.
---------------------------------------------------------------------------------------------------
Version: 0.4.6
Date: 2022-08-23

View file

@ -23,6 +23,7 @@ if data.raw.recipe["low-density-structure"] and
not data.raw.recipe["low-density-structure"].icon and
not data.raw.recipe["low-density-structure"].icons
then
-- final failsafe check, might no longer be necessary, needs testing with a lot of varied mod loadouts
util.set_subgroup("low-density-structure", data.raw.item["low-density-structure"].subgroup)
util.set_icons("low-density-structure", {
{ icon = "__base__/graphics/icons/low-density-structure.png", icon_size = 64, icon_mipmaps = 4},

View file

@ -235,6 +235,18 @@ function util.se_matter(params)
end
end
-- 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)
local technology = data.raw.technology[technology_name]

View file

@ -1,53 +1,6 @@
local util = require("data-util");
local futil = require("util")
local cutil = require("carbon-util")
if util.me.use_fullerenes() then
data:extend({
{
type = "recipe",
name = "low-density-structure-nanotubes",
icons = {
{ icon = "__base__/graphics/icons/low-density-structure.png", icon_size = 64, icon_mipmaps = 4},
{ icon = "__bzcarbon__/graphics/icons/nanotube.png", icon_size = 128, scale=0.125, shift= {-8, -8}},
},
category = "advanced-crafting",
subgroup = data.raw.item["low-density-structure"].subgroup,
order = "o[low-density-structure-nanotubes]",
},
})
if data.raw.recipe["low-density-structure"].normal and data.raw.recipe["low-density-structure"].normal.ingredients then
data.raw.recipe["low-density-structure-nanotubes"].normal = {
enabled = false,
energy_required = 20,
results = {{"low-density-structure", 2}},
ingredients = {
{"nanotubes", 2},
table.unpack(futil.table.deepcopy(data.raw.recipe["low-density-structure"].normal.ingredients)),
},
}
if data.raw.recipe["low-density-structure"].expensive and data.raw.recipe["low-density-structure"].expensive.ingredients then
data.raw.recipe["low-density-structure-nanotubes"].expensive = {
enabled = false,
energy_required = 20,
results = {{"low-density-structure", 2}},
ingredients = {
{"nanotubes", 2},
table.unpack(futil.table.deepcopy(data.raw.recipe["low-density-structure"].expensive.ingredients)),
},
}
end
else
local recipe = data.raw.recipe["low-density-structure-nanotubes"]
recipe.enabled = false
recipe.energy_required = 20
recipe.results = {{"low-density-structure", 2}}
recipe.ingredients = {
{"nanotubes", 2},
table.unpack(futil.table.deepcopy(data.raw.recipe["low-density-structure"].ingredients)),
}
end
if util.me.reuse() then
util.add_product("low-density-structure-nanotubes", {type="item", name="diamond", amount=1, probability = 0.5, catalyst_amount=1})
end
cutil.nanotube_recipe("low-density-structure")
end

View file

@ -0,0 +1,8 @@
{
"recipe": [
["imersium-gear-wheel-nanotubes", "kr-s-c-imersium-gear-wheel-nanotubes"],
["imersium-beam-nanotubes", "kr-s-c-imersium-beam-nanotubes"],
["aeroframe-scaffold-nanotubes", "se-aeroframe-scaffold-nanotubes"],
["nanomaterial-nanotubes", "se-nanomaterial-nanotubes"]
]
}