working alpha

This commit is contained in:
Brevven 2021-05-16 01:43:54 -07:00
commit 5c51be9567
91 changed files with 1343 additions and 0 deletions

20
LICENSE.md Normal file
View file

@ -0,0 +1,20 @@
The MIT License (MIT)
Copyright (c) 2021 Brevven
Permission is hereby granted, free of charge, to any person obtaining a copy of
this software and associated documentation files (the "Software"), to deal in
the Software without restriction, including without limitation the rights to
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
the Software, and to permit persons to whom the Software is furnished to do so,
subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

30
Makefile Normal file
View file

@ -0,0 +1,30 @@
# General makefile for factorio mods.
#
# Presumes the development work is done in a <factoriodir>/dev/<modname>/
# directory where this makefile resides. This directory must be parallel to
# the <factoriodir>/mods/ directory where mods are installed. Run `make
# install` from dev/<modname> to install the mod as a zip file. That zip file
# should also be ready to upload to the mod portal
.PHONY: copy lint-changelog install
pwd = $(shell pwd)
v = $(shell basename "$(pwd)")_$(shell jq -r .version info.json)
copy:
rm -rf ../$(v)
mkdir -p ../$(v)
cp -rf * ../$(v)
rm -f ../$(v).zip
cd ..; zip -9 -r -y $(v).zip $(v) -x "*.xcf" -x "*.git*" -x "*.bak"
install: lint-changelog copy
cp -f ../$(v).zip ../../mods/
lint-changelog: copy
python3 ../da-changelog-tools_0.0.14/changelog-checker.py --changelog ../$(v).zip
zorro:
python3 ../da-changelog-tools_0.0.14/changelog-checker.py --zorro --changelog ../$(v).zip

20
README.md Normal file
View file

@ -0,0 +1,20 @@
# Tungsten
[factorio mod page](https://mods.factorio.com/mod/bztungsten)
Adds tungsten ore (wolframite), tungsten plates, tungsten carbide, and rocket engine nozzles to factorio.
Modifies several recipes to use new resources and intermediates.
## Version History
See changelog.txt
## Created by
- [brevven](https://mods.factorio.com/user/brevven) (code, design, graphics)
### Thanks to
- [Gregersenpai](https://mods.factorio.com/user/Gregersenpai) for [early ideas](https://mods.factorio.com/mod/bztitanium/discussion/608eb5b4012c5f47810bf252)
- [snouz](https://mods.factorio.com/user/snouz) (alpha graphics borrowed from Titanium mod)
### Localization

6
changelog.txt Normal file
View file

@ -0,0 +1,6 @@
---------------------------------------------------------------------------------------------------
Version: 0.0.1
Date: 2021-05-16
Features:
- Tungsten added to game.
- Compatible with space exploration, krastorio2, deadlock stacking/crating, etc.

15
data-final-fixes.lua Normal file
View file

@ -0,0 +1,15 @@
require("modules")
require("tungsten-recipe-final-stacking")
require("tungsten-recipe-final-rrr")
-- require("tungsten-recipe-final-5d")
local util = require("__bztungsten__.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")
end
end

4
data-updates.lua Normal file
View file

@ -0,0 +1,4 @@
require("tungsten-recipe-updates")
require("tungsten-matter")
require("omni")
require("map-gen-preset-updates")

6
data.lua Normal file
View file

@ -0,0 +1,6 @@
require("tungsten-ore")
require("tungsten-ore-particle")
require("tungsten-recipe")
require("tungsten-enriched") -- Enriched for Krastorio 2
require("tungsten-recipe-se") -- Space Exploration special recipes (depends on K2 if present)
require("tungsten-compressed")

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.6 MiB

Binary file not shown.

Binary file not shown.

After

Width:  |  Height:  |  Size: 608 KiB

Binary file not shown.

Binary file not shown.

After

Width:  |  Height:  |  Size: 812 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 711 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 572 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 627 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 239 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 215 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 202 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 203 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 370 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 342 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 310 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 299 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 148 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 127 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 125 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 122 B

BIN
graphics/icons/Untitled.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 12 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 14 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 14 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 14 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 14 KiB

Binary file not shown.

Binary file not shown.

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.2 KiB

Binary file not shown.

Binary file not shown.

After

Width:  |  Height:  |  Size: 9.6 KiB

Binary file not shown.

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 23 KiB

Binary file not shown.

Binary file not shown.

After

Width:  |  Height:  |  Size: 16 KiB

Binary file not shown.

Binary file not shown.

After

Width:  |  Height:  |  Size: 10 KiB

Binary file not shown.

Binary file not shown.

After

Width:  |  Height:  |  Size: 12 KiB

Binary file not shown.

Binary file not shown.

After

Width:  |  Height:  |  Size: 11 KiB

Binary file not shown.

Binary file not shown.

After

Width:  |  Height:  |  Size: 13 KiB

Binary file not shown.

Binary file not shown.

After

Width:  |  Height:  |  Size: 12 KiB

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

After

Width:  |  Height:  |  Size: 11 KiB

Binary file not shown.

Binary file not shown.

Binary file not shown.

After

Width:  |  Height:  |  Size: 9.7 KiB

Binary file not shown.

Binary file not shown.

After

Width:  |  Height:  |  Size: 9.2 KiB

Binary file not shown.

Binary file not shown.

After

Width:  |  Height:  |  Size: 82 KiB

Binary file not shown.

18
info.json Normal file
View file

@ -0,0 +1,18 @@
{
"name": "bztungsten",
"version": "0.0.1",
"factorio_version": "1.1",
"title": "Tungsten",
"author": "Brevven",
"contact": "",
"homepage": "",
"dependencies": [
"base >= 1.1.0",
"? space-exploration",
"? Krastorio2",
"? deadlock-beltboxes-loaders",
"? DeadlockCrating"
],
"description": "Adds tungsten ore (wolframite), tungsten plates, tungsten carbide and rocket engine nozzles to the base game.\n\nAvailable after green science, tungsten and the various intermediates are used throughout the vanilla game. Compatible with Space Exploration and Krastorio 2, as well as several other mods. More compatibility forthcoming."
}

48
locale/en/tungsten.cfg Normal file
View file

@ -0,0 +1,48 @@
[entity-name]
tungsten-ore=Wolframite
tungsten-chest=Tungsten chest
[autoplace-control-names]
tungsten-ore=[item=tungsten-ore] Wolframite
[item-name]
tungsten-ore=Wolframite
tungsten-dust=Tungsten dust
tungsten-plate=Tungsten plate
tungsten-carbide=Tungsten carbide
rocket-engine-nozzle=Rocket engine nozzle
enriched-tungsten=Enriched tungsten
tungsten-chest=Tungsten chest
compressed-tungsten-ore=Compressed tungsten ore
[item-description]
tungsten-ore=Can be smelted into tungsten plates
enriched-tungsten=Can be efficiently smelted into tungsten plates
[technology-name]
tungsten-processing=Tungsten processing
enriched-tungsten=Enriched tungsten
tungsten-matter-processing=Tungsten conversion
[technology-description]
enriched-tungsten=Enrich tungsten ore, purifying with ammonia [fluid=ammonia] and water [fluid=water], improving the final yield. Produce dirty water [fluid=dirty-water] as a byproduct.
[recipe-name]
enriched-tungsten=__ITEM__enriched-tungsten__
tungsten-plate=__ITEM__tungsten-plate__
smelt-compressed-tungsten-ore=__ITEM__tungsten-plate__
tungsten-dust=__ITEM__tungsten-dust__
dirty-water-filtration-tungsten=Filter dirty water [item=tungsten-ore]
[recipe-description]
enriched-tungsten=Enrich tungsten ore, purifying with ammonia [fluid=ammonia] and water [fluid=water], improving the final yield. Produce dirty water [fluid=dirty-water] as a byproduct.
dirty-water-filtration-tungsten=Filter dirty water, giving wolframite [item=tungsten-ore] and stone [item=stone] (probabilistically).
# Settings
[mod-setting-name]
bztungsten-avoid-military=Avoid military science pack
[mod-setting-description]
bztungsten-avoid-military=If 'yes', rocketry will no longer require military science.

View file

@ -0,0 +1,14 @@
local base_ore = "iron-ore"
if mods["angelssmelting"] then
base_ore = "angels-ore1"
end
if data.raw["map-gen-presets"] and data.raw["map-gen-presets"].default then
for name, preset in pairs(data.raw["map-gen-presets"].default) do
if type(preset) == "table" and
preset.basic_settings and
preset.basic_settings.autoplace_controls and
preset.basic_settings.autoplace_controls[base_ore] then
preset.basic_settings.autoplace_controls["tungsten-ore"] = preset.basic_settings.autoplace_controls[base_ore]
end
end
end

27
modules.lua Normal file
View file

@ -0,0 +1,27 @@
-- Enable prod modules for all tungsten plate and ore recipes
recipes = {"tungsten-plate", "tungsten-carbide", "rocket-engine-nozzle"}
if mods["Krastorio2"] then
table.insert(recipes, "enriched-tungsten-plate")
table.insert(recipes, "enriched-tungsten")
end
if mods["space-exploration"] then
table.insert(recipes, "tungsten-smelting-vulcanite")
if mods["Krastorio2"] then
table.insert(recipes, "enriched-tungsten-smelting-vulcanite")
end
end
for i, recipe in pairs(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

6
omni.lua Normal file
View file

@ -0,0 +1,6 @@
if (not mods["pyrawores"] and not mods["bobplates"] and not mods["angelssmelting"]) then
if omni and omni.matter then
omni.matter.add_resource("tungsten-ore", omni.matter.get_ore_tier("iron-ore"))
end
end

10
settings.lua Normal file
View file

@ -0,0 +1,10 @@
data:extend(
{
{
type = "string-setting",
name = "bztungsten-avoid-military",
setting_type = "startup",
default_value = "no",
allowed_values = {"yes", "no"},
},
})

BIN
thumbnail.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 40 KiB

BIN
thumbnail.xcf Normal file

Binary file not shown.

32
tungsten-compressed.lua Normal file
View file

@ -0,0 +1,32 @@
if simpleCompress then
if simpleCompress.ores then
simpleCompress.currentSubgroup = "intermediate-product"
if data.raw.item["tungsten-ore"] then
SimpleCompress_AddTintedItem("tungsten-ore", "ore4-tungsten", "ore", {r=0.90, g=0.90, b=0.75})
SimpleCompress_UnlockOreTechAndRecipe("tungsten-ore")
end
end
if simpleCompress.plates then
simpleCompress.currentSubgroup = "intermediate-product"
if data.raw.item["tungsten-plate"] then
SimpleCompress_AddTintedItem("tungsten-plate", "plates4-tungsten", "plate3", {r=0.90, g=0.90, b=0.75})
SimpleCompress_UnlockPlateTechAndRecipe("tungsten-plate")
local tungstenRecipe = data.raw.recipe["decompress-tungsten-plate"]
tungstenRecipe.order = "d[tungsten-plate]"
end
end
if simpleCompress.smelting then
if data.raw.item["tungsten-plate"] and data.raw.item["tungsten-plate"] then
SimpleCompress_AddSmeltingRecipe("tungsten-ore", "tungsten-plate")
SimpleCompress_UnlockOreSmeltingTech("tungsten-ore")
local tungstenRecipe = data.raw.recipe["smelt-compressed-tungsten-ore"]
tungstenRecipe.results = {
{type="item", name = "tungsten-plate", amount=simpleCompress.CompressedSmeltAmount},
}
tungstenRecipe.icons = {{ icon = "__bztungsten__/graphics/icons/tungsten-plate.png", icon_size = 64 }}
tungstenRecipe.subgroup = "raw-material"
tungstenRecipe.order = "d[tungsten-plate]"
end
end
end

166
tungsten-enriched.lua Normal file
View file

@ -0,0 +1,166 @@
-- Enriched Titanium for Krastorio2
local util = require("__bztungsten__.util");
if mods["Krastorio2"] then
data:extend({
{
type = "item",
name = "enriched-tungsten",
icon_size = 64, icon_mipmaps = 3,
icon = "__bztungsten__/graphics/icons/enriched-tungsten.png",
pictures = {
{filename="__bztungsten__/graphics/icons/enriched-tungsten.png", size=64, scale=0.25},
{filename="__bztungsten__/graphics/icons/enriched-tungsten-2.png", size=64, scale=0.25},
{filename="__bztungsten__/graphics/icons/enriched-tungsten-3.png", size=64, scale=0.25},
{filename="__bztungsten__/graphics/icons/enriched-tungsten-4.png", size=64, scale=0.25},
},
subgroup = "raw-material",
order = "e05-a[enriched-ores]-a1[enriched-tungsten]",
stack_size = util.get_stack_size(100),
},
{
type = "recipe",
name = "enriched-tungsten",
icon = "__bztungsten__/graphics/icons/enriched-tungsten.png",
icon_size = 64,
category = "chemistry",
energy_required = 3,
enabled = false,
always_show_made_in = true,
always_show_products = true,
allow_productivity = true,
ingredients =
{
{type = "fluid", name = "ammonia", amount = 10},
{type = "fluid", name = "water", amount = 25, catalyst_amount = 25},
{type = "item", name = "tungsten-ore", amount = 9}
},
results =
{
{type = "item", name = "enriched-tungsten", amount = 6},
{type = "fluid", name = "dirty-water", amount = 25, catalyst_amount = 25}
},
crafting_machine_tint =
{
primary = {r = 0.721, g = 0.525, b = 0.043, a = 0.000},
secondary = {r = 0.200, g = 0.680, b = 0.300, a = 0.357},
tertiary = {r = 0.690, g = 0.768, b = 0.870, a = 0.000},
quaternary = {r = 0.0, g = 0.980, b = 0.603, a = 0.900}
},
subgroup = "raw-material",
order = "e03[enriched-tungsten]"
},
{
type = "recipe",
name = "enriched-tungsten-plate",
icons =
{
{ icon = "__bztungsten__/graphics/icons/tungsten-plate.png", icon_size = 64, icon_mipmaps = 3, },
{ icon = "__bztungsten__/graphics/icons/enriched-tungsten.png", icon_size = 64},
},
category = "smelting",
energy_required = 16,
enabled = false,
always_show_made_in = true,
always_show_products = true,
allow_productivity = true,
ingredients =
{
{"enriched-tungsten", 5}
},
result = "tungsten-plate",
result_count = 5,
order = "b[tungsten-plate]-b[enriched-tungsten-plate]"
},
{
type = "technology",
name = "enriched-tungsten",
icons =
{
{
icon = "__Krastorio2__/graphics/technologies/enriched-ores.png",
icon_size = 256,
tint = { a=1.0, b=0.75, r=0.75, g=0.75 }
},
{
icon = "__bztungsten__/graphics/icons/enriched-tungsten.png",
icon_size = 64,
scale = 2,
shift = {48, 48}
}
},
effects =
{
{
type = "unlock-recipe",
recipe = "enriched-tungsten"
},
{
type = "unlock-recipe",
recipe = "enriched-tungsten-plate"
},
{
type = "unlock-recipe",
recipe = "dirty-water-filtration-tungsten",
}
},
prerequisites = {"kr-enriched-ores", util.tungsten_processing},
unit =
{
count = 150,
ingredients =
{
{"automation-science-pack", 1},
{"logistic-science-pack", 1},
{"chemical-science-pack", 1}
},
time = 30
}
},
{
type = "recipe",
name = "dirty-water-filtration-tungsten",
category = "fluid-filtration",
icons =
{
{
icon = data.raw.fluid["dirty-water"].icon,
icon_size = data.raw.fluid["dirty-water"].icon_size
},
{
icon = data.raw.item["tungsten-ore"].icon,
icon_size = data.raw.item["tungsten-ore"].icon_size,
scale = 0.20 * (data.raw.fluid["dirty-water"].icon_size/data.raw.item["tungsten-ore"].icon_size),
shift = {0, 4}
}
},
icon_size = data.raw.fluid["dirty-water"].icon_size,
energy_required = 2,
enabled = false,
allow_as_intermediate = false,
always_show_made_in = true,
always_show_products = true,
ingredients =
{
{type = "fluid", name = "dirty-water", amount = 100, catalyst_amount = 100},
},
results =
{
{type = "fluid", name = "water", amount = 100, catalyst_amount = 100},
{type = "item", name = "stone", probability = 0.30, amount = 1},
{type = "item", name = "tungsten-ore", probability = 0.05, amount = 1}
},
crafting_machine_tint =
{
primary = {r = 0.60, g = 0.20, b = 0, a = 0.6},
secondary = {r = 1.0, g = 0.843, b = 0.0, a = 0.9}
},
subgroup = "raw-material",
order = "w013[dirty-water-filtration-tungsten]"
}
}
)
util.add_effect("kr-enriched-ores", { type = "unlock-recipe", recipe = "enriched-tungsten" })
util.add_effect("kr-enriched-ores", { type = "unlock-recipe", recipe = "enriched-tungsten-plate" })
util.add_effect("kr-enriched-ores", { type = "unlock-recipe", recipe = "dirty-water-filtration-tungsten" })
end

61
tungsten-matter.lua Normal file
View file

@ -0,0 +1,61 @@
-- Matter recipes for Krastorio2
if mods["Krastorio2"] then
local matter = require("__Krastorio2__/lib/public/data-stages/matter-util")
data:extend(
{
{
type = "technology",
name = "tungsten-matter-processing",
icons =
{
{
icon = "__Krastorio2__/graphics/technologies/matter-stone.png",
icon_size = 256,
},
{
icon = "__bztungsten__/graphics/icons/tungsten-ore.png",
icon_size = 64, icon_mipmaps = 3,
scale = 1.25,
}
},
prerequisites = {"kr-matter-processing"},
unit =
{
count = 350,
ingredients =
{
{"production-science-pack", 1},
{"utility-science-pack", 1},
{"matter-tech-card", 1}
},
time = 45
}
},
})
local tungsten_ore_matter =
{
item_name = "tungsten-ore",
minimum_conversion_quantity = 10,
matter_value = 6,
energy_required = 1,
need_stabilizer = false,
unlocked_by_technology = "tungsten-matter-processing"
}
matter.createMatterRecipe(tungsten_ore_matter)
local tungsten_plate_matter =
{
item_name = "tungsten-plate",
minimum_conversion_quantity = 10,
matter_value = 10,
energy_required = 2,
only_deconversion = true,
need_stabilizer = true,
unlocked_by_technology = "tungsten-matter-processing"
}
matter.createMatterRecipe(tungsten_plate_matter)
end

144
tungsten-ore-particle.lua Normal file
View file

@ -0,0 +1,144 @@
data:extend(
{
{
type = "optimized-particle",
name = "tungsten-ore-particle",
flags = {"not-on-map"},
life_time = 180,
pictures =
{
{
filename = "__bztungsten__/graphics/entity/tungsten-ore-particle/tungsten-ore-particle-1.png",
priority = "extra-high",
width = 16,
height = 16,
frame_count = 1,
hr_version =
{
filename = "__bztungsten__/graphics/entity/tungsten-ore-particle/hr-tungsten-ore-particle-1.png",
priority = "extra-high",
width = 32,
height = 32,
frame_count = 1,
scale = 0.5
}
},
{
filename = "__bztungsten__/graphics/entity/tungsten-ore-particle/tungsten-ore-particle-2.png",
priority = "extra-high",
width = 16,
height = 16,
frame_count = 1,
hr_version =
{
filename = "__bztungsten__/graphics/entity/tungsten-ore-particle/hr-tungsten-ore-particle-2.png",
priority = "extra-high",
width = 32,
height = 32,
frame_count = 1,
scale = 0.5
}
},
{
filename = "__bztungsten__/graphics/entity/tungsten-ore-particle/tungsten-ore-particle-3.png",
priority = "extra-high",
width = 16,
height = 16,
frame_count = 1,
hr_version =
{
filename = "__bztungsten__/graphics/entity/tungsten-ore-particle/hr-tungsten-ore-particle-3.png",
priority = "extra-high",
width = 32,
height = 32,
frame_count = 1,
scale = 0.5
}
},
{
filename = "__bztungsten__/graphics/entity/tungsten-ore-particle/tungsten-ore-particle-4.png",
priority = "extra-high",
width = 16,
height = 16,
frame_count = 1,
hr_version =
{
filename = "__bztungsten__/graphics/entity/tungsten-ore-particle/hr-tungsten-ore-particle-4.png",
priority = "extra-high",
width = 32,
height = 32,
frame_count = 1,
scale = 0.5
}
}
},
shadows =
{
{
filename = "__bztungsten__/graphics/entity/tungsten-ore-particle/tungsten-ore-particle-shadow-1.png",
priority = "extra-high",
width = 16,
height = 16,
frame_count = 1,
hr_version =
{
filename = "__bztungsten__/graphics/entity/tungsten-ore-particle/hr-tungsten-ore-particle-shadow-1.png",
priority = "extra-high",
width = 32,
height = 32,
frame_count = 1,
scale = 0.5
}
},
{
filename = "__bztungsten__/graphics/entity/tungsten-ore-particle/tungsten-ore-particle-shadow-2.png",
priority = "extra-high",
width = 16,
height = 16,
frame_count = 1,
hr_version =
{
filename = "__bztungsten__/graphics/entity/tungsten-ore-particle/hr-tungsten-ore-particle-shadow-2.png",
priority = "extra-high",
width = 32,
height = 32,
frame_count = 1,
scale = 0.5
}
},
{
filename = "__bztungsten__/graphics/entity/tungsten-ore-particle/tungsten-ore-particle-shadow-3.png",
priority = "extra-high",
width = 16,
height = 16,
frame_count = 1,
hr_version =
{
filename = "__bztungsten__/graphics/entity/tungsten-ore-particle/hr-tungsten-ore-particle-shadow-3.png",
priority = "extra-high",
width = 32,
height = 32,
frame_count = 1,
scale = 0.5
}
},
{
filename = "__bztungsten__/graphics/entity/tungsten-ore-particle/tungsten-ore-particle-shadow-4.png",
priority = "extra-high",
width = 16,
height = 16,
frame_count = 1,
hr_version =
{
filename = "__bztungsten__/graphics/entity/tungsten-ore-particle/hr-tungsten-ore-particle-shadow-4.png",
priority = "extra-high",
width = 32,
height = 32,
frame_count = 1,
scale = 0.5
}
}
}
}
}
)

87
tungsten-ore.lua Normal file
View file

@ -0,0 +1,87 @@
local resource_autoplace = require('resource-autoplace');
local util = require("__bztungsten__.util");
if mods["FactorioExtended-Plus-Core"] then
util.remove_raw("item", "tungsten-ore")
end
data:extend({
{
type = "autoplace-control",
category = "resource",
name = "tungsten-ore",
richness = true,
order = "b-e"
},
{
type = "noise-layer",
name = "tungsten-ore"
},
{
type = "resource",
icon_size = 64, icon_mipmaps = 3,
name = "tungsten-ore",
icon = "__bztungsten__/graphics/icons/tungsten-ore.png",
flags = {"placeable-neutral"},
order="a-b-a",
map_color = {r=0.90, g=0.90, b=0.80},
minable =
{
hardness = 1,
mining_particle = "tungsten-ore-particle",
mining_time = 2,
fluid_amount=(mods["Krastorio2"] and 1 or 10),
required_fluid=(mods["Krastorio2"] and "mineral-water" or "water"),
result = "tungsten-ore"
},
collision_box = {{ -0.1, -0.1}, {0.1, 0.1}},
selection_box = {{ -0.5, -0.5}, {0.5, 0.5}},
autoplace = resource_autoplace.resource_autoplace_settings{
name = "tungsten-ore",
order = "b-z",
base_density = 4,
has_starting_area_placement = false,
regular_rq_factor_multiplier = 1.0
},
stage_counts = {15000, 9500, 5500, 2900, 1300, 400, 150, 80},
stages =
{
sheet =
{
filename = "__bztungsten__/graphics/entity/ores/tungsten-ore.png",
priority = "extra-high",
size = 64,
frame_count = 8,
variation_count = 8,
hr_version =
{
filename = "__bztungsten__/graphics/entity/ores/hr-tungsten-ore.png",
priority = "extra-high",
size = 128,
frame_count = 8,
variation_count = 8,
scale = 0.5
}
}
},
},
{
type = "item",
name = "tungsten-ore",
icon_size = 64, icon_mipmaps = 3,
icon = "__bztungsten__/graphics/icons/tungsten-ore.png",
pictures = {
{filename="__bztungsten__/graphics/icons/tungsten-ore.png", size=64, scale=0.25},
{filename="__bztungsten__/graphics/icons/tungsten-ore-2.png", size=64, scale=0.25},
{filename="__bztungsten__/graphics/icons/tungsten-ore-3.png", size=64, scale=0.25},
{filename="__bztungsten__/graphics/icons/tungsten-ore-4.png", size=64, scale=0.25},
},
subgroup = "raw-resource",
order = "t-c-a",
stack_size = util.get_stack_size(50)
},
})

View file

@ -0,0 +1,15 @@
local util = require("__bztungsten__.util");
if mods["Rich-Rocks-Requiem"] then
if data.raw.recipe["rrr-stone-processing"] then
table.insert(data.raw.recipe["rrr-stone-processing"].results,
{name = "tungsten-ore", probability = 0.05, amount = 2}
)
end
if data.raw.recipe["rrr-raw-ores-processing"] then
table.insert(data.raw.recipe["rrr-raw-ores-processing"].results,
{name = "tungsten-ore", probability = 0.50, amount = 10}
)
end
end

View file

@ -0,0 +1,25 @@
-- Deadlock stacking recipes
local util = require("__bztungsten__.util");
if deadlock then
deadlock.add_stack("tungsten-ore", "__bztungsten__/graphics/icons/stacked/tungsten-ore-stacked.png", "deadlock-stacking-2", 64)
deadlock.add_stack("tungsten-plate", "__bztungsten__/graphics/icons/stacked/tungsten-plate-stacked.png" , "deadlock-stacking-2", 64)
deadlock.add_stack("tungsten-carbide", "__bztungsten__/graphics/icons/stacked/tungsten-carbide-stacked.png" , "deadlock-stacking-2", 128)
deadlock.add_stack("rocket-engine-nozzle", "__bztungsten__/graphics/icons/stacked/rocket-engine-nozzle-stacked.png" , "deadlock-stacking-2", 128)
if mods["Krastorio2"] then
deadlock.add_stack("enriched-tungsten", "__bztungsten__/graphics/icons/stacked/enriched-tungsten-stacked.png" , "deadlock-stacking-2", 64)
end
end
-- Deadlock crating recipes
if deadlock_crating then
deadlock_crating.add_crate("tungsten-ore", "deadlock-crating-2")
deadlock_crating.add_crate("tungsten-plate", "deadlock-crating-2")
deadlock_crating.add_crate("tungsten-carbide", "deadlock-crating-2")
deadlock_crating.add_crate("rocket-engine-nozzle", "deadlock-crating-2")
if mods["Krastorio2"] then
deadlock_crating.add_crate("enriched-tungsten", "deadlock-crating-2")
end
end

64
tungsten-recipe-se.lua Normal file
View file

@ -0,0 +1,64 @@
-- Additional recipes if Space Exploration mod is enabled
local util = require("__bztungsten__.util");
if mods["space-exploration"] then
se_delivery_cannon_recipes["tungsten-ore"] = {name= "tungsten-ore"}
se_delivery_cannon_recipes["tungsten_plate"] = {name= "tungsten_plate"}
if mods["Krastorio2"] then
data:extend({
{
type = "recipe",
name = "enriched-tungsten-smelting-vulcanite",
category = "smelting",
order = "d[tungsten-plate]",
energy_required = 24,
enabled = false,
always_show_made_in = true,
allow_as_intermediate = false,
ingredients = {
{name = "enriched-tungsten", amount = 8},
{name = "se-vulcanite-block", amount = 1},
},
results = {
{name = util.tungsten_plate, amount = 12},
},
icons =
{
{ icon = "__bztungsten__/graphics/icons/tungsten-plate.png", icon_size = 64, icon_mipmaps = 3 },
{ icon = "__space-exploration-graphics__/graphics/icons/vulcanite-block.png", icon_size = 64, scale=0.25, shift= {-10, -10}},
},
},
})
table.insert(data.raw.technology["se-processing-vulcanite"].effects,
{type = "unlock-recipe", recipe= "enriched-tungsten-smelting-vulcanite"})
data.raw.recipe["enriched-tungsten-plate"].order= "d[tungsten-plate]"
se_delivery_cannon_recipes["enriched-tungsten"] = {name= "enriched-tungsten"}
else
data:extend({
{
type = "recipe",
name = "tungsten-smelting-vulcanite",
category = "smelting",
order = "d[tungsten-plate]",
energy_required = 48,
enabled = false,
always_show_made_in = true,
allow_as_intermediate = false,
ingredients = {
{name = "tungsten-ore", amount = 20},
{name = "se-vulcanite-block", amount = 1},
},
results = {
{name = util.tungsten_plate, amount = 30},
},
icons =
{
{ icon = "__bztungsten__/graphics/icons/tungsten-plate.png", icon_size = 64, icon_mipmaps = 3,},
{ icon = "__space-exploration-graphics__/graphics/icons/vulcanite-block.png", icon_size = 64, scale=0.25, shift= {-10, -10}},
},
},
})
table.insert(data.raw.technology["se-processing-vulcanite"].effects,
{type = "unlock-recipe", recipe= "tungsten-smelting-vulcanite"})
end
end

154
tungsten-recipe-updates.lua Normal file
View file

@ -0,0 +1,154 @@
local util = require("__bztungsten__.util");
-- Lamps
util.add_prerequisite("optics", "tungsten-processing")
util.set_tech_recipe("optics", {{"automation-science-pack", 1}, {"logistic-science-pack", 1}})
util.add_ingredient("small-lamp", "tungsten-plate", 1)
-- Rail signals use lamps
util.add_prerequisite("rail-signals", "optics")
util.add_ingredient("rail-signal", "small-lamp", 1)
util.add_ingredient("rail-chain-signal", "small-lamp", 1)
-- Ammunition
util.add_prerequisite("military-2", "tungsten-processing")
util.replace_ingredient("piercing-rounds-magazine", "copper-plate", "tungsten-plate")
util.replace_ingredient("piercing-shotgun-shell", "copper-plate", "tungsten-plate")
util.replace_ingredient("cannon-shell", "copper-plate", "tungsten-plate")
-- Tooling
util.add_prerequisite("automation-2", "tungsten-processing")
util.replace_some_ingredient("assembling-machine-2", "steel-plate", 1, "tungsten-carbide", 1)
util.add_ingredient("assembling-machine-3", "tungsten-carbide", 4)
util.add_ingredient("chemical-plant", "tungsten-carbide", 2)
util.add_ingredient("electric-furnace", "tungsten-carbide", 1)
-- Electrodes & spark plugs
util.replace_ingredient("accumulator", "iron-plate", "tungsten-plate")
util.add_ingredient("oil-refinery", "tungsten-plate", 1)
util.add_ingredient("chemical-plant", "tungsten-plate", 1)
util.add_prerequisite("engine", "tungsten-processing")
util.add_ingredient("engine-unit", "tungsten-plate", 1)
-- Hot stuff
util.add_prerequisite("advanced-materials-processing-2", "tungsten-processing")
util.replace_some_ingredient("electric-furnace", "stone-brick", 5, "tungsten-plate", 10)
util.replace_some_ingredient("heat-exchanger", "copper-plate", 50, "tungsten-plate", 50)
util.add_ingredient("nuclear-reactor", "tungsten-plate", 500)
util.add_ingredient("flamethrower-turret", "tungsten-plate", 5)
-- Rocket engine nozzle techs
util.add_effect("rocketry", { type = "unlock-recipe", recipe = "rocket-engine-nozzle" })
util.add_prerequisite("rocket-silo", "rocketry")
if util.get_setting("bztungsten-avoid-military") == "yes" then
util.set_tech_recipe("rocketry", {{"automation-science-pack", 1}, {"logistic-science-pack", 1}})
end
-- Rocket engine nozzle uses
util.add_ingredient("rocket-part", "rocket-engine-nozzle", mods["space-exploration"] and 5 or 10)
util.add_ingredient("rocket", "rocket-engine-nozzle", 1)
util.add_ingredient("satellite", "rocket-engine-nozzle", 10)
util.add_ingredient("artillery-shell", "rocket-engine-nozzle", 3)
util.add_ingredient("atomic-bomb", "rocket-engine-nozzle", 7)
util.add_ingredient("atomic-bomb", "tungsten-plate", 1)
-- Airplanes
util.add_prerequisite("afterburner", "rocketry")
util.add_ingredient("afterburner", "rocket-engine-nozzle", 1)
-- Jetpack
util.add_prerequisite("jetpack-1", "rocketry")
util.add_ingredient("jetpack-1", "rocket-engine-nozzle", 6)
-- Other lights
util.add_ingredient("balloon-light", "tungsten-plate", 1)
util.add_ingredient("short-balloon-light", "tungsten-plate", 1)
util.add_ingredient("LargeLamp", "tungsten-plate", 1)
util.add_ingredient("StadiumLamp", "tungsten-plate", 10)
util.set_tech_recipe("optics-2", {{"automation-science-pack", 1}, {"logistic-science-pack", 1}})
util.set_tech_recipe("bright-lamp", {{"automation-science-pack", 1}, {"logistic-science-pack", 1}})
---- K2
if mods["Krastorio2"] then
util.set_tech_recipe("engine", {{"basic-tech-card", 1}, {"automation-science-pack", 1}, {"logistic-science-pack", 1}})
util.set_tech_recipe("fluid-handling", {{"basic-tech-card", 1}, {"automation-science-pack", 1}, {"logistic-science-pack", 1}})
util.set_tech_recipe("optics", {{"basic-tech-card", 1}, {"automation-science-pack", 1}, {"logistic-science-pack", 1}})
util.set_tech_recipe("oil-processing", {{"basic-tech-card", 1}, {"automation-science-pack", 1}, {"logistic-science-pack", 1}})
util.set_tech_recipe("plastics", {{"basic-tech-card", 1}, {"automation-science-pack", 1}, {"logistic-science-pack", 1}})
if util.get_setting("bztungsten-avoid-military") == "yes" then
util.set_tech_recipe("rocketry", {{"basic-tech-card", 1}, {"automation-science-pack", 1}, {"logistic-science-pack", 1}})
end
util.remove_prerequisite("kr-sentinel", "optics")
util.add_prerequisite("tungsten-processing", "kr-mineral-water-gathering")
util.remove_prerequisite("kr-mineral-water-gathering", "fluid-handling")
-- engines come later with Tungten.
util.replace_ingredient("kr-filtration-plant", "engine-unit", "pipe")
-- Heat related
util.add_ingredient("kr-fusion-reactor", "tungsten-plate", 350)
util.add_ingredient("energy-control-unit", "tungsten-plate", 3)
util.replace_some_ingredient("kr-advanced-furnace", "rare-metals", 40, "tungsten-plate", 40)
-- Other
util.add_ingredient("matter-research-data", "tungsten-plate", 5)
-- Ammunition
util.replace_ingredient("piercing-magazine", "steel-plate", "tungsten-plate")
util.replace_ingredient("armor-piercing-rifle-magazine", "steel-plate", "tungsten-plate")
util.replace_ingredient("armor-piercing-anti-material-rifle-magazine", "steel-plate", "tungsten-plate")
util.replace_ingredient("basic-railgun-shell", "steel-plate", "tungsten-plate")
-- Rocket things
util.add_ingredient("heavy-rocket", "rocket-engine-nozzle", 4)
util.add_ingredient("explosive-turret-rocket", "rocket-engine-nozzle", 3)
-- Tooling
util.add_ingredient("kr-electric-mining-drill-mk2", "tungsten-carbide", 5)
util.add_ingredient("kr-quarry-drill", "tungsten-carbide", 20)
util.replace_some_ingredient("kr-advanced-chemical-plant", "rare-metals", 40, "tungsten-carbide", 20)
end
-- SE
if mods["space-exploration"] then
-- Heat Shielding
util.replace_some_ingredient("se-heat-shielding", "steel-plate", 1, "tungsten-plate", 3)
util.replace_some_ingredient("se-heat-shielding-iridium", "stone-tablet", 3, "tungsten-plate", 3)
-- Hot stuff
util.add_ingredient("se-space-electromagnetics-laboratory", "tungsten-plate", 20)
util.add_ingredient("se-space-radiator", "tungsten-plate", 4)
util.add_ingredient("se-delivery-cannon-weapon-capsule", "tungsten-plate", 10)
-- Data
util.add_ingredient("se-electromagnetic-field-data", "tungsten-plate", 1)
util.add_product("se-electromagnetic-field-data", {name="tungsten-plate", amount=1, probability=0.95})
util.add_ingredient("se-hot-thermodynamics-data", "tungsten-plate", 1)
util.add_product("se-hot-thermodynamics-data", {name="tungsten-plate", amount=1, probability=0.50})
util.add_ingredient("se-particle-beam-shielding-data", "tungsten-plate", 1)
util.add_product("se-particle-beam-shielding-data", {name="tungsten-plate", amount=1, probability=0.20})
--rocket
util.add_ingredient("se-rocket-science-pack", "rocket-engine-nozzle", 1)
util.add_ingredient("se-spaceship-rocket-engine", "rocket-engine-nozzle", 4)
util.add_ingredient("se-cargo-rocket-section", "rocket-engine-nozzle", 5)
util.add_ingredient("se-cargo-rocket-section-beryllium", "rocket-engine-nozzle", 5)
--Tooling
util.add_ingredient("se-space-assembling-machine", "tungsten-carbide", 8)
util.add_ingredient("se-core-miner", "tungsten-carbide", 40)
util.add_ingredient("se-space-mechanical-laboratory", "tungsten-carbide", 40)
util.add_ingredient("se-recyling-facility", "tungsten-carbide", 10)
end
if mods["aai-industry"]then
util.add_ingredient("area-mining-drill", "tungsten-carbide", 8)
end

193
tungsten-recipe.lua Normal file
View file

@ -0,0 +1,193 @@
-- Lead smelting
local util = require("__bztungsten__.util");
data:extend({
{ type = "recipe-category", name = "smelting-carbon"},
})
data:extend(
{
{
type = "recipe",
name = util.tungsten_plate,
category = "smelting",
subgroup = "raw-material",
order = "d[tungsten-plate]",
icons = (mods["Krastorio2"] and
{
{ icon = "__bztungsten__/graphics/icons/tungsten-plate.png", icon_size = 64, icon_mipmaps = 3, },
{ icon = "__bztungsten__/graphics/icons/tungsten-ore.png", icon_size = 64, icon_mipmaps = 3, scale=0.25, shift= {-8, -8}},
} or {
{ icon = "__bztungsten__/graphics/icons/tungsten-plate.png", icon_size = 64, icon_mipmaps = 3, },
}
),
normal = (mods["Krastorio2"] and
{
enabled = false,
energy_required = 16,
ingredients = {{"tungsten-ore", 10}},
result = util.tungsten_plate,
result_count = 5,
} or
{
enabled = false,
energy_required = 32/15,
ingredients = {{"tungsten-ore", 2}},
result = util.tungsten_plate,
}),
expensive =
{
enabled = false,
energy_required = 9.6,
ingredients = {{"tungsten-ore", 3}},
result = util.tungsten_plate
}
},
{
type = "item",
name = util.tungsten_plate,
icon = "__bztungsten__/graphics/icons/tungsten-plate.png",
icon_size = 64, icon_mipmaps = 3,
subgroup = "raw-material",
order = "b[tungsten-plate]",
stack_size = util.get_stack_size(100)
},
{
type = "technology",
name = "tungsten-processing",
icon_size = 256, icon_mipmaps = 4,
icon = "__bztungsten__/graphics/technology/tungsten-processing.png",
effects =
{
{
type = "unlock-recipe",
recipe = util.tungsten_plate
},
{
type = "unlock-recipe",
recipe = "tungsten-carbide",
},
mods["TheBigFurnace"] and {
type = "unlock-recipe",
recipe = "big-tungsten-plate",
} or nil,
},
unit =
{
count = 75,
ingredients =
{
{"automation-science-pack", 1},
{"logistic-science-pack", 1}
},
time = 30,
},
prerequisites = {"advanced-material-processing"},
order = "b-b"
},
mods["TheBigFurnace"] and {
type = "recipe",
name = "big-tungsten-plate",
icons = { { icon = "__bztungsten__/graphics/icons/tungsten-plate.png", icon_size = 64 }, },
subgroup = "raw-material",
category = "big-smelting",
order = "d[tungsten-plate]",
normal =
{
enabled = false,
energy_required = 6, --TODO
ingredients = {{"tungsten-ore", 100}},
results = {
{type="item", name = util.tungsten_plate, amount=50},
}
},
expensive =
{
enabled = false,
energy_required = 15, --TODO
ingredients = {{"tungsten-ore", 99}},
results = {
{type="item", name = util.tungsten_plate, amount=33},
}
}
} or nil,
})
data:extend({
{
type = "item",
name = "tungsten-carbide",
icon = "__bztungsten__/graphics/icons/tungsten-carbide.png",
icon_size = 128,
subgroup = "raw-material",
order = "z[tungsten-carbide]",
stack_size = util.get_stack_size(100)
},
{
type = "recipe",
name = "tungsten-carbide",
category = (mods["Krastorio2"] and "smelting" or "smelting-carbon"),
subgroup = "raw-material",
order = "z[tungsten-carbide]",
icons = { { icon = "__bztungsten__/graphics/icons/tungsten-carbide.png", icon_size = 128} },
normal = (mods["Krastorio2"] and
{
enabled = false,
energy_required = 48,
ingredients = {{"tungsten-plate", 10}, {"coke", 5}},
result = "tungsten-carbide",
result_count = 4,
} or
{
enabled = false,
energy_required = 25.6,
ingredients = {{"tungsten-plate", 5}},
result = "tungsten-carbide",
result_count = 2,
}),
expensive =
{
enabled = false,
energy_required = 25.6,
ingredients = {{"tungsten-plate", 5}},
result = "tungsten-carbide",
}
},
})
data:extend({
{
type = "item",
name = "rocket-engine-nozzle",
icon = "__bztungsten__/graphics/icons/rocket-engine-nozzle.png",
icon_size = 128,
subgroup = "intermediate-product",
order = "z[rocket-engine-nozzle]",
stack_size = util.get_stack_size(100)
},
{
type = "recipe",
name = "rocket-engine-nozzle",
category = "crafting",
subgroup = "intermediate-product",
order = "z[rocket-engine-nozzle]",
icons = {
{ icon = "__bztungsten__/graphics/icons/rocket-engine-nozzle.png", icon_size = 128}
},
normal =
{
enabled = false,
energy_required = 5,
ingredients = {{"tungsten-plate", 2}},
result = "rocket-engine-nozzle",
},
expensive =
{
enabled = false,
energy_required = 5,
ingredients = {{"tungsten-plate", 3}},
result = "rocket-engine-nozzle",
}
}
})

178
util.lua Normal file
View file

@ -0,0 +1,178 @@
local util = {}
util.tungsten_ore = "tungsten-ore"
util.tungsten_plate = "tungsten-plate"
function util.get_setting(name)
if settings.startup[name] == nil then
return nil
end
return settings.startup[name].value
end
function util.get_stack_size(default)
if mods["Krastorio2"] then
size = tonumber(krastorio.general.getSafeSettingValue("kr-stack-size"))
return size or default
end
return default
end
-- check if a table contains a sought value
function util.contains(table, sought)
for i, value in pairs(table) do
if value == sought then
return true
end
end
return false
end
-- Add a prerequisite to a given technology
function util.add_prerequisite(technology_name, prerequisite)
technology = data.raw.technology[technology_name]
if technology and data.raw.technology[prerequisite] then
if technology.prerequisites then
table.insert(technology.prerequisites, prerequisite)
else
technology.prerequisites = {prerequisite}
end
end
end
-- Remove a prerequisite from a given technology
function util.remove_prerequisite(technology_name, prerequisite)
technology = data.raw.technology[technology_name]
local index = -1
if technology and data.raw.technology[prerequisite] then
for i, prereq in pairs(technology.prerequisites) do
if prereq == prerequisite then
index = i
break
end
end
if index > -1 then
table.remove(technology.prerequisites, index)
end
end
end
-- Add an effect to a given technology
function util.add_effect(technology_name, effect)
technology = data.raw.technology[technology_name]
if technology then
table.insert(technology.effects, effect)
end
end
-- Set technology ingredients
function util.set_tech_recipe(technology_name, ingredients)
technology = data.raw.technology[technology_name]
if technology then
technology.unit.ingredients = ingredients
end
end
-- Add a given quantity of ingredient to a given recipe
function util.add_ingredient(recipe_name, ingredient, quantity)
if data.raw.recipe[recipe_name] then
add_ingredient(data.raw.recipe[recipe_name], ingredient, quantity)
add_ingredient(data.raw.recipe[recipe_name].normal, ingredient, quantity)
add_ingredient(data.raw.recipe[recipe_name].expensive, ingredient, quantity)
end
end
function add_ingredient(recipe, ingredient, quantity)
if recipe ~= nil and recipe.ingredients ~= nil then
table.insert(recipe.ingredients, {ingredient, quantity})
end
end
-- Add a given quantity of product to a given recipe.
-- Only works for recipes with multiple products
function util.add_product(recipe_name, product)
if data.raw.recipe[recipe_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 and recipe.results ~= nil then
table.insert(recipe.results, product)
end
end
-- Replace one ingredient with another in a recipe
function util.replace_ingredient(recipe_name, old, new)
if data.raw.recipe[recipe_name] then
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)
end
end
function replace_ingredient(recipe, old, new)
if recipe ~= nil and recipe.ingredients ~= nil then
for i, ingredient in pairs(recipe.ingredients) do
-- For final fixes
if ingredient.name == old then ingredient.name = new end
-- For updates
if ingredient[1] == old then ingredient[1] = new end
end
end
end
-- Remove an ingredient from a recipe
function util.remove_ingredient(recipe_name, old)
if data.raw.recipe[recipe_name] then
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
function remove_ingredient(recipe, old)
index = -1
if recipe ~= nil and recipe.ingredients ~= nil then
for i, ingredient in pairs(recipe.ingredients) do
if ingredient.name == old or ingredient[1] == old then
index = i
break
end
end
if index > -1 then
table.remove(recipe.ingredients, index)
end
end
end
-- Replace an amount of an ingredient in a recipe. Keep at least 1 of old.
function util.replace_some_ingredient(recipe_name, old, old_amount, new, new_amount)
if data.raw.recipe[recipe_name] then
replace_some_ingredient(data.raw.recipe[recipe_name], old, old_amount, new, new_amount)
replace_some_ingredient(data.raw.recipe[recipe_name].normal, old, old_amount, new, new_amount)
replace_some_ingredient(data.raw.recipe[recipe_name].expensive, old, old_amount, new, new_amount)
end
end
function replace_some_ingredient(recipe, old, old_amount, new, new_amount)
if recipe ~= nil and recipe.ingredients ~= nil then
for i, ingredient in pairs(recipe.ingredients) do
-- For final fixes
if ingredient.name == old then
ingredient.amount = math.max(1, ingredient.amount - old_amount)
end
-- For updates
if ingredient[1] == old then
ingredient[2] = math.max(1, ingredient[2] - old_amount)
end
end
add_ingredient(recipe, new, new_amount)
end
end
return util