This commit is contained in:
Brevven 2022-06-28 03:31:07 -07:00
commit 780d3f2d3d
83 changed files with 1805 additions and 0 deletions

20
LICENSE.md Normal file
View file

@ -0,0 +1,20 @@
The MIT License (MIT)
Copyright (c) 2022 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.

37
Makefile Normal file
View file

@ -0,0 +1,37 @@
# 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
libdir = "../bzlib"
libfiles = $(shell ls $(libdir)/*.lua | grep -o '[^/]*.lua')
pwd = $(shell pwd)
v = $(shell basename "$(pwd)")_$(shell jq -r .version info.json)
link:
for f in $(libfiles) ; do \
echo "using $(libdir)/$$f" ;\
cp $(libdir)/$$f .; \
done;
copy: link
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" -x "*.blend*"
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

19
README.md Normal file
View file

@ -0,0 +1,19 @@
# Mod
[factorio mod page](https://mods.factorio.com/mod/bztin)
Adds tin to the base game
## Version History
See changelog.txt
## Created by
- [brevven](https://mods.factorio.com/user/brevven) (code, design, graphics)
## Thanks to
- [snouz](https://github.com/snouz) (logo inspiration, ore graphics templates)
- https://www.flickr.com/photos/free-stock/6837291528/ for beta solder icon (modified from public domain image)
### Localization

7
changelog.txt Normal file
View file

@ -0,0 +1,7 @@
---------------------------------------------------------------------------------------------------
Version: 0.0.1
Date: 2022-07-01
Features:
- Alpha release. Adds tin, solder, and other optional intermediates
- Compatible with Krastorio 2
- Compatible with Space Exploration

23
control-util.lua Normal file
View file

@ -0,0 +1,23 @@
local me = require("me")
local util = {}
util.me = me
function decode(data)
if type(data) == "string" then return data end
local str = {}
for i = 2, #data do
str[i-1] = decode(data[i])
end
return table.concat(str, "")
end
function util.get_list()
local p = game.item_prototypes[me.name.."-list"]
if p then
data = p.localised_description
return decode(data)
end
end
return util

16
control.lua Normal file
View file

@ -0,0 +1,16 @@
local util = require("control-util")
function on_console_chat(event)
if event.message and string.lower(event.message) == "bzlist" then
local player = game.players[event.player_index]
if player and player.connected then
local list = util.get_list()
if list and #list>0 then
local filename = util.me.name..".txt"
game.write_file(filename, list, false, event.player_index)
player.print("Wrote recipes to script-output/"..filename)
end
end
end
end
script.on_event(defines.events.on_console_chat, on_console_chat)

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

@ -0,0 +1,13 @@
-- require("tin-recipe-final-stacking")
require("tin-recipe-modules")
-- require("tin-recipe-final-5d")
require("tin-recipe-final-rrr")
local util = require("data-util");
util.replace_some_ingredient("se-glass-vulcanite", "sand", 1, "tin-plate", 1)
util.add_product("se-glass-vulcanite", {type="item", name="tin-plate", amount=1, probability=0.8})
util.set_main_product("se-glass-vulcanite", "glass")
-- Must be last
util.create_list()

10
data-updates.lua Normal file
View file

@ -0,0 +1,10 @@
require("tin-recipe-updates")
require("tin-matter")
-- require("omni")
require("map-gen-preset-updates")
require("strange-matter")
local util = require("data-util");
-- Must be last
util.create_list()

743
data-util.lua Normal file
View file

@ -0,0 +1,743 @@
-- WARNING WARNING WARNING
-- This file will be overwritten in mod zipfiles, edit bzlib/data-util.lua
-- WARNING WARNING WARNING
local me = require("me")
local util = {}
util.me = me
util.get_setting = util.me.get_setting
util.titanium_plate = ""
util.titanium_processing = ""
if mods["FactorioExtended-Plus-Core"] then
util.titanium_plate = "titanium-alloy"
else
util.titanium_plate = "titanium-plate"
end
if mods["pyrawores"] then
util.titanium_processing = "titanium-mk01"
else
util.titanium_processing = "titanium-processing"
end
function util.fe_plus(sub)
if mods["FactorioExtended-Plus-"..sub] then
return true
end
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
function util.k2assets()
if mods["Krastorio2Assets"] then
return "__Krastorio2Assets__"
end
return "__Krastorio2__/graphics"
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
-- Set/override a technology's prerequisites
function util.set_prerequisite(technology_name, prerequisites)
local technology = data.raw.technology[technology_name]
if technology then
technology.prerequisites = {}
for i, prerequisite in pairs(prerequisites) do
if data.raw.technology[prerequisite] then
table.insert(technology.prerequisites, prerequisite)
end
end
end
end
-- Add a prerequisite to a given technology
function util.add_prerequisite(technology_name, prerequisite)
local 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)
local technology = data.raw.technology[technology_name]
local index = -1
if technology 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)
local technology = data.raw.technology[technology_name]
if technology then
if not technology.effects then technology.effects = {} end
if effect and effect.type == "unlock-recipe" then
if not data.raw.recipe[effect.recipe] then
return
end
table.insert(technology.effects, effect)
end
end
end
-- remove recipe unlock effect from a given technology
function util.remove_recipe_effect(technology_name, recipe_name)
local technology = data.raw.technology[technology_name]
local index = -1
if technology then
for i, effect in pairs(technology.effects) do
if effect.type == "unlock-recipe" and effect.recipe == recipe_name then
index = i
break
end
end
if index > -1 then
table.remove(technology.effects, index)
end
end
end
-- Set technology ingredients
function util.set_tech_recipe(technology_name, ingredients)
local technology = data.raw.technology[technology_name]
if technology then
technology.unit.ingredients = ingredients
end
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
end
end
-- Add a given quantity of ingredient to a given recipe
function util.add_or_add_to_ingredient(recipe_name, ingredient, quantity)
if me.bypass[recipe_name] then return end
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
function add_or_add_to_ingredient(recipe, ingredient, quantity)
if recipe ~= nil and recipe.ingredients ~= nil then
for i, existing in pairs(recipe.ingredients) do
if existing[1] == ingredient or existing.name == ingredient then
add_to_ingredient(recipe, ingredient, quantity)
return
end
end
table.insert(recipe.ingredients, {ingredient, quantity})
end
end
-- Add a given quantity of ingredient to a given recipe
function util.add_ingredient(recipe_name, ingredient, quantity)
if me.bypass[recipe_name] then return end
local is_fluid = not not data.raw.fluid[ingredient]
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
function add_ingredient(recipe, ingredient, quantity, is_fluid)
if recipe ~= nil and recipe.ingredients ~= nil then
for i, existing in pairs(recipe.ingredients) do
if existing[1] == ingredient or existing.name == ingredient then
log("Not adding "..ingredient.." -- duplicate")
return
end
end
if is_fluid then
table.insert(recipe.ingredients, {type="fluid", name=ingredient, amount=quantity})
else
table.insert(recipe.ingredients, {ingredient, quantity})
end
end
end
-- Add a given ingredient prototype to a given recipe
function util.add_ingredient_raw(recipe_name, ingredient)
if me.bypass[recipe_name] then return end
if data.raw.recipe[recipe_name] and (data.raw.item[ingredient.name] or data.raw.item[ingredient[1]]) 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
function add_ingredient_raw(recipe, ingredient)
if recipe ~= nil and recipe.ingredients ~= nil then
for i, existing in pairs(recipe.ingredients) do
if (
(existing[1] and (existing[1] == ingredient[1] or existing[1] == ingredient.name)) or
(existing.name and (existing.name == ingredient[1] or existing.name == ingredient.name))
) then
return
end
end
table.insert(recipe.ingredients, ingredient)
end
end
-- Set an ingredient to a given quantity
function util.set_ingredient(recipe_name, ingredient, quantity)
if me.bypass[recipe_name] then return end
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
function set_ingredient(recipe, ingredient, quantity)
if recipe ~= nil and recipe.ingredients ~= nil then
for i, existing in pairs(recipe.ingredients) do
if existing[1] == ingredient then
existing[2] = quantity
return
elseif existing.name == ingredient then
existing.amount = quantity
existing.amount_min = nil
existing.amount_max = nil
return
end
end
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] and (data.raw.item[product[1]] or data.raw.item[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 not recipe.normal then
if recipe.results == nil then
recipe.results = {{recipe.result, recipe.result_count and recipe.result_count or 1}}
end
recipe.result = nil
recipe.result_count = nil
table.insert(recipe.results, product)
end
end
end
-- Replace one ingredient with another in a recipe
function util.replace_ingredient(recipe_name, old, new)
if me.bypass[recipe_name] then return end
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)
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, existing in pairs(recipe.ingredients) do
if existing[1] == new or existing.name == new then
log("Not adding "..new.." -- duplicate")
return
end
end
for i, ingredient in pairs(recipe.ingredients) do
if ingredient.name == old then ingredient.name = new end
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 me.bypass[recipe_name] then return end
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
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 me.bypass[recipe_name] then return end
local is_fluid = not not data.raw.fluid[new]
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
function replace_some_ingredient(recipe, old, old_amount, new, new_amount, is_fluid)
if recipe ~= nil and recipe.ingredients ~= nil then
for i, existing in pairs(recipe.ingredients) do
if existing[1] == new or existing.name == new then
log("Not adding "..new.." -- duplicate")
return
end
end
for i, ingredient in pairs(recipe.ingredients) do
if ingredient.name == old then
ingredient.amount = math.max(1, ingredient.amount - old_amount)
end
if ingredient[1] == old then
ingredient[2] = math.max(1, ingredient[2] - old_amount)
end
end
add_ingredient(recipe, new, new_amount, is_fluid)
end
end
-- multiply the cost, energy, and results of a recipe by a multiple
function util.multiply_recipe(recipe_name, multiple)
me.add_modified(recipe_name)
if data.raw.recipe[recipe_name] then
if me.bypass[recipe_name] then return end
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
function multiply_recipe(recipe, multiple)
if recipe then
if recipe.energy_required then
recipe.energy_required = recipe.energy_required * multiple
end
if recipe.result_count then
recipe.result_count = recipe.result_count * multiple
end
if recipe.results then
for i, result in pairs(recipe.results) do
if result.name then
if result.amount then
result.amount = result.amount * multiple
end
if result.amount_min ~= nil then
result.amount_min = result.amount_min * multiple
result.amount_max = result.amount_max * multiple
end
if result.catalyst_amount then
result.catalyst_amount = result.catalyst_amount * multiple
end
end
if result[1] then
result[2] = result[2] * multiple
end
end
end
if not recipe.results and not recipe.result_count then
-- implicit one item result
recipe.result_count = multiple
end
if recipe.ingredients then
for i, ingredient in pairs(recipe.ingredients) do
if ingredient.name then
ingredient.amount = ingredient.amount * multiple
end
if ingredient[1] then
ingredient[2] = ingredient[2] * multiple
end
end
end
end
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))
end
function has_ingredient(recipe, ingredient)
if recipe ~= nil and recipe.ingredients ~= nil then
for i, existing in pairs(recipe.ingredients) do
if existing[1] == ingredient or existing.name == ingredient then
return true
end
end
end
return false
end
-- Remove a product from a recipe, WILL NOT remove the only product
function util.remove_product(recipe_name, old)
me.add_modified(recipe_name)
if data.raw.recipe[recipe_name] then
if me.bypass[recipe_name] then return end
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
function remove_product(recipe, old)
index = -1
if recipe ~= nil and recipe.results ~= nil then
for i, result in pairs(recipe.results) do
if result.name == old or result[1] == old then
index = i
break
end
end
if index > -1 then
table.remove(recipe.results, index)
end
end
end
function util.set_main_product(recipe_name, product)
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
function set_main_product(recipe, product)
if recipe then
recipe.main_product = product
end
end
-- Replace one product with another in a recipe
function util.replace_product(recipe_name, old, new)
if data.raw.recipe[recipe_name] then
replace_product(data.raw.recipe[recipe_name], old, new)
replace_product(data.raw.recipe[recipe_name].normal, old, new)
replace_product(data.raw.recipe[recipe_name].expensive, old, new)
end
end
function replace_product(recipe, old, new)
if recipe then
if recipe.main_product == old then
recipe.main_product = new
end
if recipe.result == old then
recipe.result = new
return
end
if recipe.results then
for i, result in pairs(recipe.results) do
if result.name == old then result.name = new end
if result[1] == old then result[1] = new end
end
end
end
end
-- Remove an element of type t and name from data.raw
function util.remove_raw(t, name)
if not data.raw[t] then
log(t.." not found in data.raw")
return
end
if data.raw[t][name] then
for i, elem in pairs(data.raw[t]) do
if elem.name == name then
data.raw[t][i] = nil
break
end
end
end
end
-- Multiply energy required
function util.multiply_time(recipe_name, factor)
me.add_modified(recipe_name)
if data.raw.recipe[recipe_name] then
if me.bypass[recipe_name] then return end
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
function multiply_time(recipe, factor)
if recipe then
if recipe.energy_required then
recipe.energy_required = recipe.energy_required * factor
end
end
end
-- Add to energy required
function util.add_time(recipe_name, amount)
me.add_modified(recipe_name)
if data.raw.recipe[recipe_name] then
if me.bypass[recipe_name] then return end
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
function add_time(recipe, amount)
if recipe then
if recipe.energy_required then
recipe.energy_required = recipe.energy_required + amount
end
end
end
-- Set recipe category
function util.set_category(recipe_name, category)
if me.bypass[recipe_name] then return end
if data.raw.recipe[recipe_name] then
me.add_modified(recipe_name)
data.raw.recipe[recipe_name].category = category
end
end
-- Set recipe subgroup
function util.set_subgroup(recipe_name, subgroup)
if me.bypass[recipe_name] then return end
if data.raw.recipe[recipe_name] then
me.add_modified(recipe_name)
data.raw.recipe[recipe_name].subgroup = subgroup
end
end
-- Set recipe icons
function util.set_icons(recipe_name, icons)
if me.bypass[recipe_name] then return end
if data.raw.recipe[recipe_name] then
me.add_modified(recipe_name)
data.raw.recipe[recipe_name].icons = icons
data.raw.recipe[recipe_name].icon = nil
data.raw.recipe[recipe_name].icon_size = nil
end
end
-- Set recipe icons
function util.set_item_icons(item_name, icons)
if data.raw.item[item_name] then
data.raw.item[item_name].icons = icons
data.raw.item[item_name].icon = nil
data.raw.item[item_name].icon_size = nil
end
end
function util.set_to_founding(recipe)
util.set_category(recipe, "founding")
util.set_subgroup(recipe, "foundry-intermediate")
end
-- Add crafting category to an entity
function util.add_crafting_category(entity_type, entity, category)
if data.raw[entity_type][entity] then
for i, existing in pairs(data.raw[entity_type][entity].crafting_categories) do
if existing == category then
log(entity.." not adding "..category.." -- duplicate")
return
end
end
table.insert(data.raw[entity_type][entity].crafting_categories, category)
end
end
function util.add_to_ingredient(recipe, ingredient, amount)
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
function add_to_ingredient(recipe, it, amount)
if recipe ~= nil and recipe.ingredients ~= nil then
for i, ingredient in pairs(recipe.ingredients) do
if ingredient.name == it then
ingredient.amount = ingredient.amount + amount
return
end
if ingredient[1] == it then
ingredient[2] = ingredient[2] + amount
return
end
end
end
end
function util.add_to_product(recipe, product, amount)
if data.raw.recipe[recipe] then
add_to_product(data.raw.recipe[recipe], product, amount)
add_to_product(data.raw.recipe[recipe].normal, product, amount)
add_to_product(data.raw.recipe[recipe].expensive, product, amount)
end
end
function add_to_product(recipe, product, amount)
if recipe ~= nil and recipe.results ~= nil then
if recipe.result == product then
recipe.result_count = recipe.result_count + amount
return
end
for i, result in pairs(recipe.results) do
if result.name == product then
result.amount = result.amount + amount
return
end
if result[1] == product then
result[2] = result[2] + amount
return
end
end
end
end
-- Adds a result to a mineable type
function util.add_minable_result(t, name, result)
if data.raw[t] and data.raw[t][name] and data.raw[t][name].minable then
if data.raw[t][name].minable.result and not data.raw[t][name].minable.results then
data.raw[t][name].minable.results = {
{data.raw[t][name].minable.result ,data.raw[t][name].minable.count}}
data.raw[t][name].minable.result = nil
data.raw[t][name].minable.result_count = nil
end
if data.raw[t][name].minable.results then
table.insert(data.raw[t][name].minable.results, result)
end
end
end
local function insert(nodes, node, value)
table.insert(node, value) -- store as parameter
if 21 == #node then
node = {""}
table.insert(nodes, node)
end
return node
end
local function encode(data)
local node = {""}
local root = {node}
local n = string.len(data)
for i = 1,n,200 do
local value = string.sub(data, i, i+199)
node = insert(root, node, value)
end
while #root > 20 do
local nodes,node = {},{""}
for _, value in ipairs(root) do
node = insert(nodes, node, value)
end
root = nodes
end
if #root == 1 then root = root[1] else
table.insert(root, 1, "") -- no locale template
end
return #root < 3 and (root[2] or "") or root
end
function decode(data)
if type(data) == "string" then return data end
local str = {}
for i = 2, #data do
str[i-1] = decode(data[i])
end
return table.concat(str, "")
end
function util.create_list()
if #me.list>0 then
if not data.raw.item[me.name.."-list"] then
data:extend({{
type="item",
name=me.name.."-list",
localised_description = "",
enabled=false,
icon = "__core__/graphics/empty.png",
icon_size = 1,
stack_size = 1,
flags = {"hidden", "hide-from-bonus-gui"}
}})
end
local have = {}
local list = {}
for i, recipe in pairs(me.list) do
if not have[recipe] then
have[recipe] = true
table.insert(list, recipe)
end
end
if #list>0 then
data.raw.item[me.name.."-list"].localised_description =
encode(decode(data.raw.item[me.name.."-list"].localised_description).."\n"..table.concat(list, "\n"))
end
end
end
return util

9
data.lua Normal file
View file

@ -0,0 +1,9 @@
require("tin-ore")
require("tin-recipe")
-- require("tin-enriched") -- Enriched Al for Krastorio 2
-- require("tin-recipe-se") -- Space Exploration
local util = require("data-util");
-- Must be last
util.create_list()

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.9 MiB

Binary file not shown.

Binary file not shown.

After

Width:  |  Height:  |  Size: 517 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 14 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: 14 KiB

Binary file not shown.

Binary file not shown.

After

Width:  |  Height:  |  Size: 14 KiB

Binary file not shown.

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.8 KiB

Binary file not shown.

BIN
graphics/icons/solder.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 23 KiB

BIN
graphics/icons/solder.xcf Normal file

Binary file not shown.

Binary file not shown.

After

Width:  |  Height:  |  Size: 33 KiB

Binary file not shown.

Binary file not shown.

After

Width:  |  Height:  |  Size: 17 KiB

Binary file not shown.

Binary file not shown.

After

Width:  |  Height:  |  Size: 21 KiB

Binary file not shown.

Binary file not shown.

After

Width:  |  Height:  |  Size: 22 KiB

Binary file not shown.

Binary file not shown.

After

Width:  |  Height:  |  Size: 8 KiB

Binary file not shown.

Binary file not shown.

After

Width:  |  Height:  |  Size: 19 KiB

Binary file not shown.

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.1 KiB

Binary file not shown.

Binary file not shown.

After

Width:  |  Height:  |  Size: 17 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 28 KiB

Binary file not shown.

Binary file not shown.

After

Width:  |  Height:  |  Size: 20 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: 13 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: 9 KiB

Binary file not shown.

BIN
graphics/icons/tin-ore.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 12 KiB

BIN
graphics/icons/tin-ore.xcf Normal file

Binary file not shown.

Binary file not shown.

After

Width:  |  Height:  |  Size: 15 KiB

Binary file not shown.

Binary file not shown.

After

Width:  |  Height:  |  Size: 9.3 KiB

Binary file not shown.

Binary file not shown.

After

Width:  |  Height:  |  Size: 18 KiB

Binary file not shown.

Binary file not shown.

After

Width:  |  Height:  |  Size: 14 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.4 KiB

Binary file not shown.

Binary file not shown.

After

Width:  |  Height:  |  Size: 38 KiB

Binary file not shown.

25
info.json Normal file
View file

@ -0,0 +1,25 @@
{
"name": "bztin",
"version": "0.0.1",
"factorio_version": "1.1",
"title": "Tin",
"author": "Brevven",
"contact": "",
"homepage": "",
"dependencies": [
"base >= 1.1.0",
"bzfoundry",
"? bztitanium >= 1.1.1",
"? bzlead",
"? bzzirconium >= 0.5.4",
"? bztungsten >= 0.5.4",
"? bzcarbon >= 0.2.0",
"? space-exploration",
"? aai-industry",
"? Krastorio2",
"? deadlock-beltboxes-loaders",
"? DeadlockCrating"
],
"description": "Adds tin to the base game.\n\nCompatible with Krastorio 2 and Space Exploration. A standalone piece of BZ Mods."
}

58
locale/en/tin.cfg Normal file
View file

@ -0,0 +1,58 @@
[entity-name]
tin-ore=Tin ore
[autoplace-control-names]
tin-ore=Tin ore
[item-name]
tin-ore=Tin ore
tin-dust=Tin dust
tin-plate=Tin plate
solder=Solder
tinned-cable=Tinned cable
enriched-tin=Enriched tin
compressed-tin-ore=Compressed tin ore
[item-description]
tin-ore=Can be smelted into tin plates
enriched-tin=Can be efficiently smelted into tin plates
[fluid-name]
organotins=Organotins
[technology-name]
tinned-cable=Tinned cable
organotins=Organotins
tin-matter-processing=Tin conversion
[technology-description]
enriched-tin=Enrich tin ore, purifying with sulfuric acid [fluid=sulfuric-acid] and water [fluid=water], improving the final yield. Produce dirty water [fluid=dirty-water] as a byproduct.
tinned-cable=Tinned copper cables
[recipe-name]
alumina=__ITEM__alumina__
enriched-tin=__ITEM__enriched-tin__
tin-plate=__ITEM__tin-plate__
smelt-compressed-tin-ore=__ITEM__tin-plate__
tin-dust=__ITEM__tin-dust__
dirty-water-filtration-tin=Filter dirty water [item=tin-ore]
bz-tin-ingot=Tin ingot
[recipe-description]
enriched-tin=Enrich tin ore, purifying with sulfuric acid [fluid=sulfuric-acid] and water [fluid=water], improving the final yield. Produce dirty water [fluid=dirty-water] as a byproduct.
dirty-water-filtration-tin=Filter dirty water, giving tin ore [item=tin-ore] and other outputs (probabilistically).
# Settings
[mod-setting-name]
bztin-recipe-bypass=Bypass recipes
bztin-list=Make a list of modified recipes
bztin-more-intermediates=Enable more intermediates
[mod-setting-description]
bztin-recipe-bypass=Skip modifying these recipes (comma-separated list).
bztin-list=If enabled, the text command [color=orange]BZList[/color] will dump a file to the script-output directory with a full list of recipes modified.\nRecommended to turn this off after you are done configuring your other settings.
[string-mod-setting]
bztin-more-intermediates-no=No
bztin-more-intermediates-cable=Yes: Tinned cable

View file

@ -0,0 +1,10 @@
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["iron-ore"] then
preset.basic_settings.autoplace_controls["tin-ore"] = preset.basic_settings.autoplace_controls["iron-ore"]
end
end
end

31
me.lua Normal file
View file

@ -0,0 +1,31 @@
local me = {}
me.name = "bztin"
me.list = {}
function me.use_cable()
return me.get_setting("bztin-more-intermediates") == "cable"
end
function me.get_setting(name)
if settings.startup[name] == nil then
return nil
end
return settings.startup[name].value
end
me.bypass = {}
if me.get_setting(me.name.."-recipe-bypass") then
for recipe in string.gmatch(me.get_setting(me.name.."-recipe-bypass"), '[^",%s]+') do
me.bypass[recipe] = true
end
end
function me.add_modified(name)
if me.get_setting(me.name.."-list") then
table.insert(me.list, name)
end
end
return me

22
settings.lua Normal file
View file

@ -0,0 +1,22 @@
data:extend({
{
type = "string-setting",
name = "bztin-recipe-bypass",
setting_type = "startup",
default_value = "",
allow_blank = true,
},
{
type = "bool-setting",
name = "bztin-list",
setting_type = "startup",
default_value = false,
},
{
type = "string-setting",
name = "bztin-more-intermediates",
setting_type = "startup",
default_value = (mods.Krastorio2 or mods["space-exploration"]) and "cable" or "no",
allowed_values = {"cable", "no"},
},
})

48
strange-matter.lua Normal file
View file

@ -0,0 +1,48 @@
local util = require("data-util");
local ore = "tin-ore"
local ore_icon = "__bztin__/graphics/icons/tin-ore.png"
if mods["StrangeMatter"] then
data:extend({
{
type = "recipe",
name = ore.."-synthesis",
icons = {
{ icon = ore_icon, icon_size = 64 },
{ icon = "__StrangeMatter__/graphics/icons/fluid/matter.png", icon_size = 32, scale=0.5, shift= {-8, -8}},
},
enabled = false,
energy_required = 1,
ingredients = {{type="fluid", name="strange-matter", amount = 2}},
result = ore,
category = "crafting-with-fluid",
subgroup = "synthesis",
},
{
type = "technology",
name = ore.."-synthesis",
icons = {
{ icon = "__StrangeMatter__/graphics/icons/fluid/matter.png", icon_size = 32, shift= {-6, 0}},
{ icon = ore_icon, icon_size = 64, scale=0.25, shift={8, 8}},
},
prerequisites = {"stone-synthesis"},
effects = {
{
type = "unlock-recipe",
recipe = ore.."-synthesis",
},
},
unit = {
count = 800,
time = 30,
ingredients = {
{"automation-science-pack", 1},
{"logistic-science-pack", 1},
{"chemical-science-pack", 1},
{"production-science-pack", 1},
}
}
}
})
end

BIN
thumbnail.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 24 KiB

BIN
thumbnail.xcf Normal file

Binary file not shown.

119
tin-enriched.lua Normal file
View file

@ -0,0 +1,119 @@
-- Enriched Lead for Krastorio2
local util = require("data-util");
if mods["Krastorio2"] then
data:extend(
{
{
type = "item",
name = "enriched-tin",
icon_size = 128,
icon = "__bztin__/graphics/icons/enriched-tin.png",
pictures = {
{filename="__bztin__/graphics/icons/enriched-tin.png", size=128, scale=0.125},
{filename="__bztin__/graphics/icons/enriched-tin-1.png", size=128, scale=0.125},
{filename="__bztin__/graphics/icons/enriched-tin-2.png", size=128, scale=0.125},
{filename="__bztin__/graphics/icons/enriched-tin-3.png", size=128, scale=0.125},
},
subgroup = "raw-material",
order = "e05-a[enriched-ores]-a1[enriched-tin]",
stack_size = util.get_stack_size(100)
},
{
type = "recipe",
name = "enriched-tin",
icon = "__bztin__/graphics/icons/enriched-tin.png",
icon_size = 128,
category = "chemistry",
energy_required = 3,
enabled = false,
always_show_made_in = true,
always_show_products = true,
allow_productivity = true,
ingredients =
{
{type = "fluid", name = "sulfuric-acid", amount = 3},
{type = "fluid", name = "water", amount = 25, catalyst_amount = 25},
{type = "item", name = "tin-ore", amount = 9}
},
results =
{
{type = "item", name = "enriched-tin", 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-tin]"
},
{
type = "recipe",
name = "enriched-alumina",
icons =
{
{ icon = "__bztin__/graphics/icons/alumina.png", icon_size = 128 },
{ icon = "__bztin__/graphics/icons/enriched-tin.png", icon_size = 128, scale=0.125, shift= {-8, -8}},
},
category = "smelting",
energy_required = 16,
enabled = false,
always_show_made_in = true,
always_show_products = true,
allow_productivity = true,
ingredients = { {"enriched-tin", 5} },
results = { {"alumina", 5} },
order = "b[alumina]-b[enriched-alumina]",
},
{
type = "recipe",
name = "dirty-water-filtration-tin",
category = "fluid-filtration",
icons =
{
{
icon = data.raw.fluid["dirty-water"].icon,
icon_size = data.raw.fluid["dirty-water"].icon_size
},
{
icon = data.raw.item["tin-ore"].icon,
icon_size = data.raw.item["tin-ore"].icon_size,
scale = 0.20 * (data.raw.fluid["dirty-water"].icon_size/data.raw.item["tin-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 = 90, catalyst_amount = 90},
mods.bzsilicon and {type = "item", name = "silica", amount = 1} or
{type = "item", name = "stone", probability = 0.40, amount = 1},
{type = "item", name = "tin-ore", probability = 0.10, 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-tin]"
}
}
)
util.add_effect("kr-enriched-ores", { type = "unlock-recipe", recipe = "enriched-tin" })
util.add_effect("kr-enriched-ores", { type = "unlock-recipe", recipe = "enriched-alumina" })
util.add_effect("kr-enriched-ores", { type = "unlock-recipe", recipe = "dirty-water-filtration-tin" })
end

71
tin-matter.lua Normal file
View file

@ -0,0 +1,71 @@
-- Matter recipes for Krastorio2
if mods["Krastorio2"] then
local util = require("data-util");
local matter = require("__Krastorio2__/lib/public/data-stages/matter-util")
data:extend(
{
{
type = "technology",
name = "tin-matter-processing",
icons =
{
{
icon = util.k2assets().."/technologies/matter-coal.png",
icon_size = 256,
},
{
icon = "__bztin__/graphics/icons/tin-ore.png",
icon_size = 64,
scale = 1.4,
}
},
prerequisites = {"kr-matter-processing"},
unit =
{
count = 350,
ingredients =
{
{"production-science-pack", 1},
{"utility-science-pack", 1},
{"matter-tech-card", 1}
},
time = 45
}
},
})
local flake_graphite_matter =
{
item_name = "tin-ore",
minimum_conversion_quantity = 10,
matter_value = 5,
energy_required = 1,
need_stabilizer = false,
unlocked_by_technology = "tin-matter-processing"
}
matter.createMatterRecipe(flake_graphite_matter)
local graphite_matter =
{
item_name = "alumina",
minimum_conversion_quantity = 10,
matter_value = 7.5,
energy_required = 2,
only_deconversion = true,
need_stabilizer = true,
unlocked_by_technology = "tin-matter-processing"
}
matter.createMatterRecipe(graphite_matter)
local graphite_matter =
{
item_name = "tin-plate",
minimum_conversion_quantity = 10,
matter_value = 10,
energy_required = 3,
only_deconversion = true,
need_stabilizer = true,
unlocked_by_technology = "tin-matter-processing"
}
matter.createMatterRecipe(graphite_matter)
end

83
tin-ore.lua Normal file
View file

@ -0,0 +1,83 @@
local resource_autoplace = require('resource-autoplace');
local noise = require('noise');
local util = require("data-util");
data:extend({
{
type = "autoplace-control",
category = "resource",
name = "tin-ore",
richness = true,
order = "b-e"
},
{
type = "noise-layer",
name = "tin-ore"
},
{
type = "resource",
icon_size = 64, icon_mipmaps = 3,
name = "tin-ore",
icon = "__bztin__/graphics/icons/tin-ore.png",
flags = {"placeable-neutral"},
order="a-b-a",
map_color = {r=0.90, g=1.00, b=0.10},
minable =
{
hardness = 1,
mining_particle = "copper-ore-particle",
mining_time = 1,
result = "tin-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 = "tin-ore",
order = "b-z",
base_density = 3,
base_spots_per_km2 = 1,
has_starting_area_placement = true,
regular_rq_factor_multiplier = 1.0,
starting_rq_factor_multiplier = 1.3,
},
stage_counts = {15000, 9500, 5500, 2900, 1300, 400, 150, 80},
stages =
{
sheet =
{
filename = "__bztin__/graphics/entity/ores/tin-ore.png",
priority = "extra-high",
size = 64,
frame_count = 8,
variation_count = 8,
hr_version =
{
filename = "__bztin__/graphics/entity/ores/hr-tin-ore.png",
priority = "extra-high",
size = 128,
frame_count = 8,
variation_count = 8,
scale = 0.5
}
}
},
},
{
type = "item",
name = "tin-ore",
icon_size = 64, icon_mipmaps = 3,
icon = "__bztin__/graphics/icons/tin-ore.png",
pictures = {
{filename="__bztin__/graphics/icons/tin-ore.png", size=64, scale=0.25},
{filename="__bztin__/graphics/icons/tin-ore-2.png", size=64, scale=0.25},
{filename="__bztin__/graphics/icons/tin-ore-3.png", size=64, scale=0.25},
{filename="__bztin__/graphics/icons/tin-ore-4.png", size=64, scale=0.25},
},
subgroup = "raw-resource",
order = "t-c-a",
stack_size = util.get_stack_size(50)
},
})

16
tin-recipe-final-rrr.lua Normal file
View file

@ -0,0 +1,16 @@
local util = require("data-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 = "tin-ore", probability = 0.25, amount = 1}
)
end
if data.raw.recipe["rrr-raw-ores-processing"] then
table.insert(data.raw.recipe["rrr-raw-ores-processing"].results,
{name = "tin-ore", probability = 0.75, amount = 10}
)
end
end

View file

@ -0,0 +1,21 @@
-- Deadlock stacking recipes
local util = require("data-util");
if deadlock then
deadlock.add_stack("tin-ore", "__bztin__/graphics/icons/stacked/tin-ore-stacked.png", "deadlock-stacking-1", 64)
deadlock.add_stack("tin-plate", "__bztin__/graphics/icons/stacked/tin-plate-stacked.png", "deadlock-stacking-1", 128)
deadlock.add_stack("solder", "__bztin__/graphics/icons/stacked/solder-stacked.png", "deadlock-stacking-1", 128)
if mods.Krastorio2 then
deadlock.add_stack("enriched-tin", "__bztin__/graphics/icons/stacked/enriched-tin-ore-stacked.png" , "deadlock-stacking-3", 128)
end
end
-- Deadlock crating recipes
if deadlock_crating then
deadlock_crating.add_crate("tin-ore", "deadlock-crating-1")
deadlock_crating.add_crate("tin-plate", "deadlock-crating-1")
deadlock_crating.add_crate("solder", "deadlock-crating-1")
end

26
tin-recipe-modules.lua Normal file
View file

@ -0,0 +1,26 @@
-- Enable prod modules for all tin plate and ore recipes
recipes = {"tin-plate", "solder", "organotins"}
if mods["Krastorio2"] then
table.insert(recipes, "enriched-tin")
end
if mods["space-exploration"] then
table.insert(recipes, "tin-smelting-vulcanite")
if mods["Krastorio2"] then
table.insert(recipes, "enriched-tin-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

133
tin-recipe-se.lua Normal file
View file

@ -0,0 +1,133 @@
-- Additional recipes if Space Exploration mod is enabled
local util = require("data-util");
if mods["space-exploration"] then
se_delivery_cannon_recipes["tin-ore"] = {name= "tin-ore"}
se_delivery_cannon_recipes["alumina"] = {name= "alumina"}
se_delivery_cannon_recipes["tin-plate"] = {name= "tin-plate"}
data:extend({
{
type = "recipe",
icons = {
{ icon = "__base__/graphics/icons/landfill.png", icon_size = 64, icon_mipmaps = 3 },
{ icon = "__bztin__/graphics/icons/tin-ore.png", icon_size = 64, scale = 0.25},
},
name = "landfill-tin-ore",
category = "hard-recycling",
order = "z-b-tin",
subgroup = "terrain",
result = "landfill",
ingredients = {{"tin-ore", 50}},
}
})
data:extend({
{
type = "recipe",
icons = {
{ icon = "__base__/graphics/icons/landfill.png", icon_size = 64, icon_mipmaps = 3 },
{ icon = "__bztin__/graphics/icons/tin-ore.png", icon_size = 64, scale = 0.25},
},
name = "landfill-tin-ore",
category = "hard-recycling",
order = "z-b-tin",
subgroup = "terrain",
result = "landfill",
ingredients = {{"tin-ore", 50}},
}
})
if mods["Krastorio2"] then
data:extend({
{
type = "recipe",
name = "enriched-alumina-smelting-vulcanite",
category = "smelting",
order = "d[alumina]",
energy_required = 24,
enabled = false,
always_show_made_in = true,
allow_as_intermediate = false,
ingredients = {
{name = "enriched-tin", amount = 8},
{name = "se-vulcanite-block", amount = 1},
},
results = {
{name = "alumina", amount = 12},
},
icons =
{
{ icon = "__bztin__/graphics/icons/alumina.png", icon_size = 128 },
{ 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-alumina-smelting-vulcanite"})
data.raw.recipe["enriched-alumina"].order= "d[alumina]"
se_delivery_cannon_recipes["enriched-tin"] = {name= "enriched-tin"}
else
data:extend({
{
type = "recipe",
name = "alumina-smelting-vulcanite",
category = "smelting",
subgroup = "plates",
order = "d[alumina]",
energy_required = 24,
enabled = false,
always_show_made_in = true,
allow_as_intermediate = false,
ingredients = {
{name = "tin-ore", amount = 8},
{name = "se-vulcanite-block", amount = 1},
},
results = {
{name = "alumina", amount = 10},
{name = "silica", amount = 2},
},
icons =
{
{ icon = "__bztin__/graphics/icons/alumina.png", icon_size = 128},
{ icon = "__space-exploration-graphics__/graphics/icons/vulcanite-block.png", icon_size = 64, icon_mipmaps = 3, scale=0.25, shift= {-10, -10}},
},
},
})
table.insert(data.raw.technology["se-processing-vulcanite"].effects,
{type = "unlock-recipe", recipe= "alumina-smelting-vulcanite"})
end
data:extend({
{
type = "recipe",
name = "tin-plate-smelting-vulcanite",
category = "smelting",
subgroup = "plates",
order = "d[tin-plate]",
energy_required = 24,
enabled = false,
always_show_made_in = true,
allow_as_intermediate = false,
ingredients = {
{name = "alumina", amount = 8},
{name = "se-vulcanite-block", amount = 1},
},
results = {
{name = "tin-plate", amount = 12},
},
icons =
{
{ icon = "__bztin__/graphics/icons/tin-plate.png", icon_size = 128},
{ icon = "__space-exploration-graphics__/graphics/icons/vulcanite-block.png", icon_size = 64, icon_mipmaps = 3, scale=0.25, shift= {-10, -10}},
},
},
})
table.insert(data.raw.technology["se-processing-vulcanite"].effects,
{type = "unlock-recipe", recipe= "tin-plate-smelting-vulcanite"})
end

78
tin-recipe-updates.lua Normal file
View file

@ -0,0 +1,78 @@
local util = require("data-util");
-- Main vanilla changes
local organotins_quant = mods.Krastorio2 and 10 or 5
util.replace_some_ingredient("plastic-bar", "petroleum-gas", organotins_quant, "organotins", organotins_quant)
util.replace_some_ingredient("pipe-to-ground", "lead-plate", 3, "solder", 3)
util.replace_some_ingredient("pipe-to-ground", "iron-plate", 3, "solder", 3)
util.multiply_recipe("electronic-circuit", 2)
util.replace_some_ingredient("electronic-circuit", "copper-cable", 1, "solder", 1)
util.replace_some_ingredient("advanced-circuit", "copper-cable", 1, "solder", 1)
util.add_ingredient("chemical-plant", "solder", 5)
util.add_ingredient("oil-refinery", "solder", 5)
util.add_ingredient("assembling-machine-2", "solder", 5)
util.add_ingredient("rocket-silo", "solder", 100)
-- glass
if mods.Krastorio2 then
util.replace_some_ingredient("glass", "sand", 1, "tin-plate", 1)
util.add_product("glass", {type="item", name="tin-plate", amount=1, probability=0.8})
util.set_main_product("glass", "glass")
elseif mods["aai-industry"] then
if mods.bzfoundry then
if not mods.bzaluminum then
util.multiply_recipe("glass-from-sand", 4)
end
util.replace_some_ingredient("glass-from-sand", "sand", 1, "tin-plate", 1)
util.add_product("glass-from-sand", {type="item", name="tin-plate", amount=1, probability=0.8})
util.set_main_product("glass-from-sand", "glass")
util.set_to_founding("glass-from-sand")
end
end
-- NOTE: K2 seems to reset this recipe, so moved to final fixes
-- util.replace_some_ingredient("se-glass-vulcanite", "sand", 1, "tin-plate", 1)
-- util.add_product("se-glass-vulcanite", {type="item", name="tin-plate", amount=1, probability=0.8})
-- util.set_main_product("se-glass-vulcanite", "glass")
-- end glass
util.add_product("se-scrap-recycling", {name="tin-ore", amount=1, probability=0.05})
util.add_ingredient("se-experimental-alloys-data", "tin-plate", 1)
util.add_to_product("se-experimental-alloys-data", "se-experimental-alloys-data", 1)
util.add_to_product("se-experimental-alloys-data", "se-scrap", 1)
util.add_to_ingredient("se-experimental-alloys-data", "se-empty-data", 1)
util.multiply_recipe("lithium-sulfur-battery", 2)
util.replace_some_ingredient("lithium-sulfur-battery", "copper-plate", 1, "tin-plate", 1)
if util.me.use_cable() then
util.add_prerequisite("circuit-network", "tinned-cable")
util.replace_ingredient("arithmetic-combinator", "copper-cable", "tinned-cable")
util.replace_ingredient("decider-combinator", "copper-cable", "tinned-cable")
util.replace_ingredient("constant-combinator", "copper-cable", "tinned-cable")
util.replace_ingredient("power-switch", "copper-cable", "tinned-cable")
util.replace_ingredient("programmable-speaker", "copper-cable", "tinned-cable")
local modded_combinators = {"timer-combinator", "counting-combinator", "random-combinator",
"power-combinator", "max-combinator", "min-combinator", "and-gate-combinator",
"nand-gate-combinator", "nor-gate-combinator", "not-gate-combinator", "or-gate-combinator",
"xnor-gate-combinator", "xor-gate-combinator", "converter-combinator", "detector-combinator",
"sensor-combinator", "railway-combinator", "color-combinator", "daytime-combinator",
"statistic-combinator", "pollution-combinator", "emitter-combinator", "receiver-combinator",
"crafting_combinator:crafting-combinator",
"crafting_combinator:recipe-combinator",
"clock-combinator",
"power-meter-combinator",
"ghost-scanner",
"item-sensor",
"bi-pollution-sensor",
}
for i, v in pairs(modded_combinators) do
util.replace_ingredient(v, "copper-cable", "tinned-cable")
end
end

167
tin-recipe.lua Normal file
View file

@ -0,0 +1,167 @@
-- Aluminum smelting
local util = require("data-util");
local futil = require("util");
if (not mods["pyrawores"] and not mods["bobplates"] and not mods["angelssmelting"] ) then
data:extend({
{
type = "recipe",
name = "tin-plate",
category = "smelting",
subgroup = "raw-material",
order = "d[tin-plate]",
icons = (mods["Krastorio2"] and
{
{ icon = "__bztin__/graphics/icons/tin-plate.png", icon_size = 128},
{ icon = "__bztin__/graphics/icons/tin-ore.png", icon_size = 64, scale=0.125, shift= {-8, -8}},
} or {
{ icon = "__bztin__/graphics/icons/tin-plate.png", icon_size = 128},
}
),
normal = (mods["Krastorio2"] and
{
enabled = true,
energy_required = 12,
ingredients = {{"tin-ore", 10}},
results = {
{type="item", name = "tin-plate", amount=10}
}
} or
{
enabled = true,
energy_required = 2.4,
ingredients = {{"tin-ore", 1}},
results = {
{type="item", name = "tin-plate", amount=1}
}
}),
expensive =
{
enabled = true,
energy_required = 4.8,
ingredients = {{"tin-ore", 1}},
results = {
{type="item", name = "tin-plate", amount=1},
}
}
},
{
type = "item",
name = "tin-plate",
icon = "__bztin__/graphics/icons/tin-plate.png",
icon_size = 128,
subgroup = "raw-material",
order = "b[tin-plate]",
stack_size = util.get_stack_size(100)
},
})
local solder_ingredeents = {{"tin-plate", 4}, {"copper-plate"}, 1}
if mods.bzlead then
solder_ingredeents = {{"tin-plate", 3}, {"lead-plate", 2}}
end
data:extend({
{
type = "item",
name = "solder",
icon = "__bztin__/graphics/icons/solder.png",
icon_size = 128,
subgroup = "intermediate-product",
order = "b[acsr-cable]",
stack_size = util.get_stack_size(100),
},
{
type = "recipe",
name = "solder",
category = "crafting",
order = "d[acsr-cable]",
enabled = true,
energy_required = 1,
ingredients = solder_ingredeents,
results = {{"solder", 5}},
}
})
data:extend({
{
type = "fluid",
name = "organotins",
default_temperature = 25,
heat_capacity = "0.1KJ",
base_color = {r=0.75, g=0.65, b=0.1},
flow_color = {r=0.7, g=1, b=0.1},
icon = "__bztin__/graphics/icons/organotins.png",
icon_size = 64,
order = "a[fluid]-f[organotins]"
},
{
type = "recipe",
name = "organotins",
category = "oil-processing",
subgroup = "fluid-recipes",
order = "d[organotins]",
enabled = true,
energy_required = 5,
ingredients = {{"tin-plate", 3}, {type="fluid", name="petroleum-gas", amount=20}},
results = {{type="fluid", name="organotins", amount=50}},
},
{
type = "technology",
name = "organotins",
icon = "__bztin__/graphics/technology/organotins.png",
icon_size = 256,
effects = {
{ type = "unlock-recipe", recipe = "organotins" },
},
unit = {
count = 50, time = 30,
ingredients = {{"automation-science-pack", 1}, {"logistic-science-pack", 1}},
},
prerequisites = {"oil-processing"},
order = "b-b",
},
})
util.add_prerequisite("plastics", "organotins")
if util.me.use_cable() then
data:extend({
{
type = "item",
name = "tinned-cable",
icon = "__bztin__/graphics/icons/tinned-cable.png",
icon_size = 64, icon_mipmaps = 4,
subgroup = "intermediate-product",
order = "b[tinned-cable]",
stack_size = util.get_stack_size(100),
},
{
type = "recipe",
name = "tinned-cable",
category = "crafting",
order = "d[tinned-cable]",
enabled = true,
energy_required = 1.5,
ingredients = {{"tin-plate", 1}, {"copper-cable", 4}},
results = {{"tinned-cable", 4}},
},
{
type = "technology",
name = "tinned-cable",
icon = "__bztin__/graphics/icons/tinned-cable.png",
icon_size = 64, icon_mipmaps = 4,
effects = {
{ type = "unlock-recipe", recipe = "tinned-cable" },
},
unit = {
count = 50, time = 15,
ingredients = {{"automation-science-pack", 1}, {"logistic-science-pack", 1}},
},
prerequisites = {"logistic-science-pack"},
order = "b-b",
},
})
end
end