Compare commits

..

No commits in common. "f82be366dac3752937891657a4cde4d724ec7f40" and "4c6345cdbc7357e4e4d63fe5d7ccc42d99a34983" have entirely different histories.

122 changed files with 749 additions and 478 deletions

View file

@ -1,3 +0,0 @@
[*]
indent_style = space
indent_size = 2

1
.github/CODEOWNERS vendored Normal file
View file

@ -0,0 +1 @@
* brevven

2
.gitignore vendored
View file

@ -1,2 +0,0 @@
.idea
*.zip

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

View file

@ -1,7 +1,7 @@
local futil = require("util");
local util = require("data-util");
local util = require("__bztungsten__.data-util");
if util.me.get_setting("bztungsten-advanced-carbon-furnace") == "yes" and not mods.Krastorio2 and not mods.bzfoundry2 then
if util.me.get_setting("bztungsten-advanced-carbon-furnace") == "yes" and not mods.Krastorio2 and not mods.bzfoundry then
log("Using advanced carbon furnace")
data:extend({
{
@ -20,8 +20,8 @@ if util.me.get_setting("bztungsten-advanced-carbon-furnace") == "yes" and not mo
{
type = "recipe",
name = "advanced-carbon-furnace",
ingredients = {{type="item", name="steel-furnace", amount=2}, {type="item", name="stone-brick", amount=5}, {type="item", name="tungsten-plate", amount=5}},
results = {{type="item", name="advanced-carbon-furnace", amount=1}},
ingredients = {{"steel-furnace", 2}, {"stone-brick", 5}, {"tungsten-plate", 5}},
result = "advanced-carbon-furnace",
energy_required = 6,
enabled = false,
},
@ -102,9 +102,9 @@ if util.me.get_setting("bztungsten-advanced-carbon-furnace") == "yes" and not mo
energy_source =
{
type = "burner",
fuel_categories = {"chemical"},
fuel_category = "chemical",
effectivity = 1,
emissions_per_minute = {["pollution"] = 4},
emissions_per_minute = 4,
fuel_inventory_size = 1,
light_flicker =
{
@ -130,16 +130,35 @@ if util.me.get_setting("bztungsten-advanced-carbon-furnace") == "yes" and not mo
{
filename = "__base__/graphics/entity/steel-furnace/steel-furnace.png",
priority = "high",
width = 85,
height = 87,
frame_count = 1,
shift = futil.by_pixel(-1.5, 1.5),
tint = {a = 1, r = .55, g = .6, b = .6},
hr_version =
{
filename = "__base__/graphics/entity/steel-furnace/hr-steel-furnace.png",
priority = "high",
width = 171,
height = 174,
frame_count = 1,
shift = futil.by_pixel(-1.25, 2),
scale = 0.5,
tint = {a = 1, r = .55, g = .6, b = .6},
}
},
{
filename = "__base__/graphics/entity/steel-furnace/steel-furnace-shadow.png",
priority = "high",
width = 139,
height = 43,
frame_count = 1,
draw_as_shadow = true,
shift = futil.by_pixel(39.5, 11.5),
hr_version =
{
filename = "__base__/graphics/entity/steel-furnace/hr-steel-furnace-shadow.png",
priority = "high",
width = 277,
height = 85,
frame_count = 1,
@ -148,6 +167,7 @@ if util.me.get_setting("bztungsten-advanced-carbon-furnace") == "yes" and not mo
scale = 0.5
}
}
}
},
working_visualisations =
{
@ -161,12 +181,24 @@ if util.me.get_setting("bztungsten-advanced-carbon-furnace") == "yes" and not mo
filename = "__base__/graphics/entity/steel-furnace/steel-furnace-fire.png",
priority = "high",
line_length = 8,
width = 29,
height = 40,
frame_count = 48,
direction_count = 1,
shift = futil.by_pixel(-0.5, 6),
hr_version =
{
animation_speed = 0.25,
filename = "__base__/graphics/entity/steel-furnace/hr-steel-furnace-fire.png",
priority = "high",
line_length = 8,
width = 57,
height = 81,
frame_count = 48,
direction_count = 1,
shift = futil.by_pixel(-0.75, 5.75),
scale = 0.5
}
},
},
{
@ -193,6 +225,17 @@ if util.me.get_setting("bztungsten-advanced-carbon-furnace") == "yes" and not mo
filename = "__base__/graphics/entity/steel-furnace/steel-furnace-working.png",
priority = "high",
line_length = 1,
width = 64,
height = 74,
frame_count = 1,
direction_count = 1,
shift = futil.by_pixel(0, -4),
blend_mode = "additive",
hr_version =
{
filename = "__base__/graphics/entity/steel-furnace/hr-steel-furnace-working.png",
priority = "high",
line_length = 1,
width = 128,
height = 150,
frame_count = 1,
@ -201,6 +244,7 @@ if util.me.get_setting("bztungsten-advanced-carbon-furnace") == "yes" and not mo
blend_mode = "additive",
scale = 0.5,
}
}
},
{
draw_as_light = true,
@ -213,6 +257,18 @@ if util.me.get_setting("bztungsten-advanced-carbon-furnace") == "yes" and not mo
priority = "high",
line_length = 1,
draw_as_sprite = false,
width = 78,
height = 64,
frame_count = 1,
direction_count = 1,
shift = futil.by_pixel(0, 48),
blend_mode = "additive",
hr_version =
{
filename = "__base__/graphics/entity/steel-furnace/hr-steel-furnace-ground-light.png",
priority = "high",
line_length = 1,
draw_as_sprite = false,
width = 152,
height = 126,
frame_count = 1,
@ -220,6 +276,7 @@ if util.me.get_setting("bztungsten-advanced-carbon-furnace") == "yes" and not mo
shift = futil.by_pixel(1, 48),
blend_mode = "additive",
scale = 0.5,
}
},
},
},

View file

@ -1,86 +0,0 @@
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
function util.force_enable_recipe(event, recipe_name)
if game.players[event.player_index].force.recipes[recipe_name] then
game.players[event.player_index].force.recipes[recipe_name].enabled=true
end
end
function util.warptorio2_expansion_helper()
if script.active_mods["warptorio2_expansion"] then
function check_container_for_items(container,items)
local has_all =true
for k=1,#items do
if container.get_item_count(items[k].name)<items[k].count then has_all=false break end
end
return has_all
end
function remove_items_from_container(container,items)
for k=1,#items do
container.remove_item(items[k])
end
end
script.on_nth_tick(60, function (event)
if global.done then return end
local fix_items={
{name='iron-plate',count=100},
{name='iron-gear-wheel',count=100},
{name='repair-pack',count=50},
}
local entities = {}
for i=1,100 do
if game.surfaces[i] then
local lentities= game.surfaces[i].find_entities_filtered{area = {{-100, -100}, {100, 100}}, name = "wpe_broken_lab"}
for j, entity in pairs(lentities) do
table.insert(entities, entity)
end
end
end
if #entities == 0 then
if global.checking then
-- The lab has already been fixed
global.done = true
else
-- Check that the lab doesn't reappear due to a warp
global.checking = true
end
return
end
if check_container_for_items(entities[1],fix_items) then
remove_items_from_container(entities[1],fix_items)
local lab = entities[1].surface.create_entity({name='wpe_repaired_lab', position=entities[1].position, force = game.forces.player})
lab.destructible=false
lab.minable=false
entities[1].destroy()
global.done = true
end
end)
end
end
return util

View file

@ -1,9 +0,0 @@
-- Enable prod modules for all tungsten plate and ore recipes
local util = require("data-util");
for i, recipe in pairs(util.me.recipes) do
if data.raw.recipe[recipe] then
data.raw.recipe[recipe].allow_productivity = true
end
end

View file

@ -1,22 +0,0 @@
-- Matter recipes for Krastorio2
if mods["Krastorio2"] then
local util = require("data-util");
local matter = require("__Krastorio2__/prototypes/libraries/matter")
matter.make_recipes({
material = { type = "item", name = "tungsten-ore", amount = 1 },
matter_count = 6,
energy_required = 1,
need_stabilizer = false,
unlocked_by_technology = "tungsten-matter-processing",
icon = {icon = "__bztungsten2__/graphics/icons/tungsten-ore.png", icon_size = 64, scale = 1.25}
})
matter.make_recipes({
material = { type = "item", name = "tungsten-plate", amount = 1 },
matter_count = 10,
energy_required = 2,
need_stabilizer = false,
unlocked_by_technology = "tungsten-matter-processing",
})
end

View file

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

View file

@ -1,16 +1,4 @@
---------------------------------------------------------------------------------------------------
Version: 0.7.13
Date: 2024-03-18
Fixes:
- Fix soft lock when used with both Omnimatter and Krastorio 2
---------------------------------------------------------------------------------------------------
Version: 0.7.12
Date: 2023-12-22
Fixes:
- Fix a softlock when used with Bob's MCI (bobplates) thanks to KiwiHawk
Localization:
- ja updates thanks to Sakuro
---------------------------------------------------------------------------------------------------
Version: 0.7.11
Date: 2023-04-10
Fixes:

View file

@ -1,6 +1,6 @@
local util = require("data-util");
local util = require("__bztungsten__.data-util");
if mods["248k-Redux"] then
if mods["248k"] then
local cuw = util.me.cuw() and "cuw" or "tungsten-plate"
util.add_ingredient("fu_ingot_recipe", cuw, 20)
util.add_ingredient("fu_plasma_recipe", cuw, 40)

29
control-util.lua Normal file
View file

@ -0,0 +1,29 @@
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
function util.force_enable_recipe(event, recipe_name)
if game.players[event.player_index].force.recipes[recipe_name] then
game.players[event.player_index].force.recipes[recipe_name].enabled=true
end
end
return util

View file

@ -5,7 +5,7 @@ require("tungsten-recipe-final-rrr")
local util = require("data-util");
local util = require("__bztungsten__.data-util");
-- Only burners can make tungsten carbide in vanilla
for i, entity in pairs(data.raw.furnace) do
@ -29,7 +29,7 @@ if mods["space-exploration"] then
-- core mining balancing
util.add_to_product("se-core-fragment-omni", "tungsten-ore", -3)
if util.se6() then
if string.sub(mods["space-exploration"], 1, 3) == "0.6" then
util.add_prerequisite("rocket-silo", "rocketry")
end
end

View file

@ -44,7 +44,7 @@ if get_setting("bz-recipe-bypass") then
end
function util.is_foundry()
return mods.bzfoundry2 and not me.get_setting("bzfoundry-minimal")
return mods.bzfoundry and not me.get_setting("bzfoundry-minimal")
end
function should_force(options)
@ -64,6 +64,16 @@ function util.fe_plus(sub)
end
end
function util.get_stack_size(default)
if mods.Krastorio2 then
local size = get_setting("kr-stack-size")
if size and tonumber(size) then
return tonumber(size)
end
end
return default
end
function util.k2assets()
if mods["Krastorio2Assets"] then
return "__Krastorio2Assets__"
@ -101,8 +111,8 @@ function util.se_landfill(params)
category = "hard-recycling",
order = "z-b-"..params.ore,
subgroup = "terrain",
results = {{type="item", name="landfill", amount=1}},
ingredients = {{type="item", name=params.ore, amount=50}},
result = "landfill",
ingredients = {{params.ore, 50}},
}
})
util.add_unlock("se-recycling-facility", lname)
@ -113,7 +123,7 @@ end
-- k2 matter
-- params: {k2matter}, k2baseicon , {icon}
function util.k2matter(params)
local matter = require("__Krastorio2__/prototypes/libraries/matter")
local matter = require("__Krastorio2__/lib/public/data-stages/matter-util")
if mods["space-exploration"] then
params.k2matter.need_stabilizer = true
end
@ -121,13 +131,6 @@ function util.k2matter(params)
params.k2matter.minimum_conversion_quantity = 10
end
if not data.raw.technology[params.k2matter.unlocked_by_technology] then
local icon = ""
if params.k2baseicon then
icon = util.k2assets().."/technologies/matter-"..params.k2baseicon..".png"
else
icon = util.k2assets().."/technologies/backgrounds/matter.png"
end
data:extend(
{
{
@ -136,7 +139,7 @@ function util.k2matter(params)
icons =
{
{
icon = icon,
icon = util.k2assets().."/technologies/matter-"..params.k2baseicon..".png",
icon_size = 256,
},
params.icon,
@ -145,29 +148,18 @@ function util.k2matter(params)
unit =
{
count = 350,
ingredients = mods["space-exploration"] and
{
{"automation-science-pack", 1},
{"logistic-science-pack", 1},
{"chemical-science-pack", 1},
{"se-astronomic-science-pack-4", 1},
{"se-energy-science-pack-4", 1},
{"se-material-science-pack-4", 1},
{"se-deep-space-science-pack-2", 1},
{"se-kr-matter-science-pack-2", 1},
} or
ingredients =
{
{"production-science-pack", 1},
{"utility-science-pack", 1},
{"kr-matter-tech-card", 1}
{"matter-tech-card", 1}
},
time = 45,
},
localised_name = {"technology-name.k2-conversion", {"item-name."..params.k2matter.item_name}},
}
},
})
end
matter.make_recipes(params.k2matter)
matter.createMatterRecipe(params.k2matter)
end
@ -201,16 +193,16 @@ function util.se_matter(params)
energy_required = params.energy_required,
enabled = false,
ingredients = {
{type="item", name=sedata, amount=1},
{sedata, 1},
{type="fluid", name="se-particle-stream", amount=50},
{type="fluid", name="se-space-coolant-supercooled", amount=25},
},
results = {
{type="item", name=params.ore, amount=params.quant_out},
{type="item", name="se-contaminated-scrap", amount=1},
{type="item", name=sedata, amount=1, probability=.99},
{type="item", name=sejunk, amount=1, probability=.01},
{type="fluid", name="se-space-coolant-hot", amount=25, ignored_by_productivity=25, ignored_by_stats=25},
{params.ore, params.quant_out},
{"se-contaminated-scrap", 1},
{type=item, name=sedata, amount=1, probability=.99},
{type=item, name=sejunk, amount=1, probability=.01},
{type="fluid", name="se-space-coolant-hot", amount=25, catalyst_amount=25},
}
}
})
@ -240,14 +232,14 @@ function util.se_matter(params)
energy_required = 30,
enabled = false,
ingredients = {
{type="item", name="se-kr-matter-liberation-data", amount=1},
{type="item", name=params.ore, amount=params.quant_in},
{"se-kr-matter-liberation-data", 1},
{params.ore, params.quant_in},
{type="fluid", name="se-particle-stream", amount=50},
},
results = {
{type="item", name="se-kr-matter-liberation-data", amount=1, probability=.99},
{type="item", name=sejunk, amount=1, probability=.01},
{type="fluid", name="se-particle-stream", amount=params.stream_out, ignored_by_productivity=50, ignored_by_stats=50},
{type=item, name="se-kr-matter-liberation-data", amount=1, probability=.99},
{type=item, name=sejunk, amount=1, probability=.01},
{type="fluid", name="se-particle-stream", amount=params.stream_out, catalyst_amount=50},
}
}
})
@ -274,7 +266,7 @@ function util.se_matter(params)
{"se-astronomic-science-pack-4", 1},
{"se-energy-science-pack-4", 1},
{"se-material-science-pack-4", 1},
{"kr-matter-tech-card", 1},
{"matter-tech-card", 1},
{"se-deep-space-science-pack-1", 1},
}
@ -288,6 +280,18 @@ function util.se_matter(params)
end
end
-- Get the normal prototype for a recipe -- either .normal or the recipe itself
function util.get_normal(recipe_name)
if data.raw.recipe[recipe_name] then
recipe = data.raw.recipe[recipe_name]
if recipe.normal and recipe.normal.ingredients then
return recipe.normal
elseif recipe.ingredients then
return recipe
end
end
end
-- Set/override a technology's prerequisites
function util.set_prerequisite(technology_name, prerequisites)
local technology = data.raw.technology[technology_name]
@ -354,7 +358,7 @@ function util.add_unlock(technology_name, recipe)
end
-- Check if a tech unlocks a recipe
function util.check_unlock(technology_name, recipe)
function util.check_unlock(technology_name, recipe_name)
local technology = data.raw.technology[technology_name]
if technology and technology.effects then
for i, effect in pairs(technology.effects) do
@ -399,13 +403,17 @@ end
function util.set_enabled(recipe_name, enabled)
if data.raw.recipe[recipe_name] then
data.raw.recipe[recipe_name].enabled = enabled
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
function util.set_hidden(recipe_name)
if data.raw.recipe[recipe_name] then
data.raw.recipe[recipe_name].hidden = true
if data.raw.recipe[recipe_name].normal then data.raw.recipe[recipe_name].normal.hidden = true end
if data.raw.recipe[recipe_name].expensive then data.raw.recipe[recipe_name].expensive.hidden = true end
if not data.raw.recipe[recipe_name].normal then data.raw.recipe[recipe_name].hidden = true end
end
end
@ -415,6 +423,8 @@ function util.add_or_add_to_ingredient(recipe_name, ingredient, quantity, option
if data.raw.recipe[recipe_name] and data.raw.item[ingredient] then
me.add_modified(recipe_name)
add_or_add_to_ingredient(data.raw.recipe[recipe_name], ingredient, quantity)
add_or_add_to_ingredient(data.raw.recipe[recipe_name].normal, ingredient, quantity)
add_or_add_to_ingredient(data.raw.recipe[recipe_name].expensive, ingredient, quantity)
end
end
@ -437,6 +447,8 @@ function util.add_ingredient(recipe_name, ingredient, quantity, options)
if data.raw.recipe[recipe_name] and (data.raw.item[ingredient] or is_fluid) then
me.add_modified(recipe_name)
add_ingredient(data.raw.recipe[recipe_name], ingredient, quantity, is_fluid)
add_ingredient(data.raw.recipe[recipe_name].normal, ingredient, quantity, is_fluid)
add_ingredient(data.raw.recipe[recipe_name].expensive, ingredient, quantity, is_fluid)
end
end
@ -450,7 +462,7 @@ function add_ingredient(recipe, ingredient, quantity, is_fluid)
if is_fluid then
table.insert(recipe.ingredients, {type="fluid", name=ingredient, amount=quantity})
else
table.insert(recipe.ingredients, {type="item", name=ingredient, amount=quantity})
table.insert(recipe.ingredients, {ingredient, quantity})
end
end
end
@ -461,6 +473,8 @@ function util.add_ingredient_raw(recipe_name, ingredient, options)
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
@ -482,27 +496,27 @@ end
function util.set_ingredient(recipe_name, ingredient, quantity, options)
if not should_force(options) and bypass(recipe_name) then return end
if data.raw.recipe[recipe_name] and data.raw.item[ingredient] then
local is_fluid = not not data.raw.fluid[ingredient]
me.add_modified(recipe_name)
set_ingredient(data.raw.recipe[recipe_name], ingredient, quantity, is_fluid)
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, is_fluid)
function set_ingredient(recipe, ingredient, quantity)
if recipe ~= nil and recipe.ingredients ~= nil then
for i, existing in pairs(recipe.ingredients) do
if existing.name == ingredient then
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
if is_fluid then
table.insert(recipe.ingredients, {type="fluid", name=ingredient, amount=quantity})
else
table.insert(recipe.ingredients, {type="item", name=ingredient, amount=quantity})
end
table.insert(recipe.ingredients, {ingredient, quantity})
end
end
-- Add a given quantity of product to a given recipe.
@ -510,31 +524,47 @@ end
function util.add_product(recipe_name, product, options)
if not should_force(options) and bypass(recipe_name) then return end
if data.raw.recipe[recipe_name] and
(data.raw.item[product.name] or data.raw.fluid[product.name]) then
(data.raw.item[product[1]] or data.raw.item[product.name] or
data.raw.fluid[product[1]] or data.raw.fluid[product.name]
) then
add_product(data.raw.recipe[recipe_name], product)
add_product(data.raw.recipe[recipe_name].normal, product)
add_product(data.raw.recipe[recipe_name].expensive, product)
end
end
function add_product(recipe, product)
if recipe ~= nil then
if (product[1] and data.raw.item[product[1]]) or
(product.name and data.raw[product.type][product.name]) then
if not recipe.normal then
if recipe.results == nil then
recipe.results = {}
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
end
-- Get the amount of the ingredient, will check base/normal not expensive
function util.get_ingredient_amount(recipe_name, ingredient_name)
local recipe = data.raw.recipe[recipe_name]
if recipe then
if recipe.ingredients then
if recipe.normal and recipe.normal.ingredients then
for i, ingredient in pairs(recipe.normal.ingredients) do
if ingredient[1] == ingredient_name then return ingredient[2] end
if ingredient.name == ingredient_name then return ingredient.amount end
end
elseif recipe.ingredients then
for i, ingredient in pairs(recipe.ingredients) do
if ingredient[1] == ingredient_name then return ingredient[2] end
if ingredient.name == ingredient_name then return ingredient.amount end
end
end
return 1
return 0
end
return 0
end
@ -544,7 +574,14 @@ function util.get_amount(recipe_name, product)
if not product then product = recipe_name end
local recipe = data.raw.recipe[recipe_name]
if recipe then
if recipe.results then
if recipe.normal and recipe.normal.results then
for i, result in pairs(recipe.normal.results) do
if result[1] == product then return result[2] end
if result.name == product then return result.amount end
end
elseif recipe.normal and recipe.normal.result_count then
return recipe.normal.result_count
elseif recipe.results then
for i, result in pairs(recipe.results) do
if result[1] == product then return result[2] end
if result.name == product then return result.amount end
@ -562,7 +599,9 @@ function util.get_result_count(recipe_name, product)
if not product then product = recipe_name end
local recipe = data.raw.recipe[recipe_name]
if recipe then
if recipe.results then
if recipe.normal and recipe.normal.results then
return #(recipe.normal.results)
elseif recipe.results then
return #(recipe.results)
end
return 1
@ -577,6 +616,8 @@ function util.replace_ingredient(recipe_name, old, new, amount, multiply, option
if data.raw.recipe[recipe_name] and (data.raw.item[new] or data.raw.fluid[new]) then
me.add_modified(recipe_name)
replace_ingredient(data.raw.recipe[recipe_name], old, new, amount, multiply)
replace_ingredient(data.raw.recipe[recipe_name].normal, old, new, amount, multiply)
replace_ingredient(data.raw.recipe[recipe_name].expensive, old, new, amount, multiply)
end
end
@ -618,6 +659,8 @@ function util.remove_ingredient(recipe_name, old, options)
if data.raw.recipe[recipe_name] then
me.add_modified(recipe_name)
remove_ingredient(data.raw.recipe[recipe_name], old)
remove_ingredient(data.raw.recipe[recipe_name].normal, old)
remove_ingredient(data.raw.recipe[recipe_name].expensive, old)
end
end
@ -643,23 +686,28 @@ function util.replace_some_product(recipe_name, old, old_amount, new, new_amount
if data.raw.recipe[recipe_name] and (data.raw.item[new] or is_fluid) then
me.add_modified(recipe_name)
replace_some_product(data.raw.recipe[recipe_name], old, old_amount, new, new_amount, is_fluid)
replace_some_product(data.raw.recipe[recipe_name].normal, old, old_amount, new, new_amount, is_fluid)
replace_some_product(data.raw.recipe[recipe_name].expensive, old, old_amount, new, new_amount, is_fluid)
end
end
function replace_some_product(recipe, old, old_amount, new, new_amount, is_fluid)
function replace_some_product(recipe, old, old_amount, new, new_amount)
if recipe ~= nil then
if recipe.result == new then return end
if recipe.results then
for i, existing in pairs(recipe.results) do
if existing.name == new then
if existing[1] == new or existing.name == new then
return
end
end
end
add_product(recipe, {type=is_fluid and "fluid" or "item", name=new, amount=new_amount})
add_product(recipe, {new, new_amount})
for i, product in pairs(recipe.results) do
if product.name == old then
product.amount = math.max(1, product.amount - old_amount)
end
if product[1] == old then
product[2] = math.max(1, product[2] - old_amount)
end
end
end
@ -672,6 +720,8 @@ function util.replace_some_ingredient(recipe_name, old, old_amount, new, new_amo
if data.raw.recipe[recipe_name] and (data.raw.item[new] or is_fluid) then
me.add_modified(recipe_name)
replace_some_ingredient(data.raw.recipe[recipe_name], old, old_amount, new, new_amount, is_fluid)
replace_some_ingredient(data.raw.recipe[recipe_name].normal, old, old_amount, new, new_amount, is_fluid)
replace_some_ingredient(data.raw.recipe[recipe_name].expensive, old, old_amount, new, new_amount, is_fluid)
end
end
@ -700,6 +750,8 @@ function util.set_product_amount(recipe_name, product, amount, options)
me.add_modified(recipe_name)
if data.raw.recipe[recipe_name] then
set_product_amount(data.raw.recipe[recipe_name], product, amount)
set_product_amount(data.raw.recipe[recipe_name].normal, product, amount)
set_product_amount(data.raw.recipe[recipe_name].expensive, product, amount)
end
end
@ -738,6 +790,8 @@ function util.multiply_recipe(recipe_name, multiple, options)
me.add_modified(recipe_name)
if data.raw.recipe[recipe_name] then
multiply_recipe(data.raw.recipe[recipe_name], multiple)
multiply_recipe(data.raw.recipe[recipe_name].normal, multiple)
multiply_recipe(data.raw.recipe[recipe_name].expensive, multiple)
end
end
@ -745,6 +799,8 @@ function multiply_recipe(recipe, multiple)
if recipe then
if recipe.energy_required then
recipe.energy_required = recipe.energy_required * multiple
else
recipe.energy_required = 0.5 * multiple -- 0.5 is factorio default
end
if recipe.result_count then
recipe.result_count = recipe.result_count * multiple
@ -759,11 +815,8 @@ function multiply_recipe(recipe, multiple)
result.amount_min = result.amount_min * multiple
result.amount_max = result.amount_max * multiple
end
if result.ignored_by_productivity then
result.ignored_by_productivity = result.ignored_by_productivity * multiple
end
if result.ignored_by_stats then
result.ignored_by_stats = result.ignored_by_stats * multiple
if result.catalyst_amount then
result.catalyst_amount = result.catalyst_amount * multiple
end
end
if result[1] then
@ -790,8 +843,9 @@ 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)
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)
@ -811,6 +865,8 @@ function util.remove_product(recipe_name, old, options)
me.add_modified(recipe_name)
if data.raw.recipe[recipe_name] then
remove_product(data.raw.recipe[recipe_name], old)
remove_product(data.raw.recipe[recipe_name].normal, old)
remove_product(data.raw.recipe[recipe_name].expensive, old)
end
end
@ -833,6 +889,8 @@ function util.set_main_product(recipe_name, product, options)
if not should_force(options) and bypass(recipe_name) then return end
if data.raw.recipe[recipe_name] then
set_main_product(data.raw.recipe[recipe_name], product)
set_main_product(data.raw.recipe[recipe_name].normal, product)
set_main_product(data.raw.recipe[recipe_name].expensive, product)
end
end
@ -846,11 +904,13 @@ end
function util.replace_product(recipe_name, old, new, options)
if not should_force(options) and bypass(recipe_name) then return end
if data.raw.recipe[recipe_name] then
replace_product(data.raw.recipe[recipe_name], old, new)
replace_product(data.raw.recipe[recipe_name], old, new, options)
replace_product(data.raw.recipe[recipe_name].normal, old, new, options)
replace_product(data.raw.recipe[recipe_name].expensive, old, new, options)
end
end
function replace_product(recipe, old, new)
function replace_product(recipe, old, new, options)
if recipe then
if recipe.main_product == old then
recipe.main_product = new
@ -890,6 +950,8 @@ function util.set_recipe_time(recipe_name, time, options)
me.add_modified(recipe_name)
if data.raw.recipe[recipe_name] then
set_recipe_time(data.raw.recipe[recipe_name], time)
set_recipe_time(data.raw.recipe[recipe_name].normal, time)
set_recipe_time(data.raw.recipe[recipe_name].expensive, time)
end
end
@ -907,6 +969,8 @@ function util.multiply_time(recipe_name, factor, options)
me.add_modified(recipe_name)
if data.raw.recipe[recipe_name] then
multiply_time(data.raw.recipe[recipe_name], factor)
multiply_time(data.raw.recipe[recipe_name].normal, factor)
multiply_time(data.raw.recipe[recipe_name].expensive, factor)
end
end
@ -924,6 +988,8 @@ function util.add_time(recipe_name, amount, options)
me.add_modified(recipe_name)
if data.raw.recipe[recipe_name] then
add_time(data.raw.recipe[recipe_name], amount)
add_time(data.raw.recipe[recipe_name].normal, amount)
add_time(data.raw.recipe[recipe_name].expensive, amount)
end
end
@ -947,7 +1013,7 @@ end
-- Set recipe subgroup
function util.set_subgroup(recipe_name, subgroup, options)
if not should_force(options) and bypass(recipe_name) then return end
if data.raw.recipe[recipe_name] then
if data.raw.recipe[recipe_name] and data.raw["item-subgroup"][subgroup] then
me.add_modified(recipe_name)
data.raw.recipe[recipe_name].subgroup = subgroup
end
@ -966,17 +1032,35 @@ function util.add_icon(recipe_name, icon, options)
if data.raw.recipe[recipe_name] then
me.add_modified(recipe_name)
if not (data.raw.recipe[recipe_name].icons and #(data.raw.recipe[recipe_name].icons) > 0) then
data.raw.recipe[recipe_name].icons = {}
if data.raw.recipe[recipe_name].icon then
data.raw.recipe[recipe_name].icons = {{
icon=data.raw.recipe[recipe_name].icon,
icon_size=data.raw.recipe[recipe_name].icon_size,
icon_mipmaps=data.raw.recipe[recipe_name].icon_mipmaps,
}}
elseif data.raw.item[data.raw.recipe[recipe_name].main_product] then
data.raw.recipe[recipe_name].icons = {{
icon=data.raw.item[data.raw.recipe[recipe_name].main_product].icon,
icon_size=data.raw.item[data.raw.recipe[recipe_name].main_product].icon_size,
icon_mipmaps=data.raw.item[data.raw.recipe[recipe_name].main_product].icon_mipmaps,
}}
elseif data.raw.item[data.raw.recipe[recipe_name].result] then
data.raw.recipe[recipe_name].icons = {{
icon=data.raw.item[data.raw.recipe[recipe_name].result].icon,
icon_size=data.raw.item[data.raw.recipe[recipe_name].result].icon_size,
icon_mipmaps=data.raw.item[data.raw.recipe[recipe_name].result].icon_mipmaps,
}}
elseif data.raw.recipe[recipe_name].normal and
data.raw.item[data.raw.recipe[recipe_name].normal.result] then
data.raw.recipe[recipe_name].icons = {{
icon=data.raw.item[data.raw.recipe[recipe_name].normal.result].icon,
icon_size=data.raw.item[data.raw.recipe[recipe_name].normal.result].icon_size,
icon_mipmaps=data.raw.item[data.raw.recipe[recipe_name].normal.result].icon_mipmaps,
}}
end
data.raw.recipe[recipe_name].icon = nil
data.raw.recipe[recipe_name].icon_size = nil
end
end
table.insert(data.raw.recipe[recipe_name].icons, icon)
end
end
@ -1035,6 +1119,8 @@ function util.add_to_ingredient(recipe, ingredient, amount, options)
if not should_force(options) and bypass(recipe_name) then return end
if data.raw.recipe[recipe] then
add_to_ingredient(data.raw.recipe[recipe], ingredient, amount)
add_to_ingredient(data.raw.recipe[recipe].normal, ingredient, amount)
add_to_ingredient(data.raw.recipe[recipe].expensive, ingredient, amount)
end
end
@ -1057,6 +1143,8 @@ function util.add_to_product(recipe_name, product, amount, options)
if not should_force(options) and bypass(recipe_name) then return end
if data.raw.recipe[recipe_name] then
add_to_product(data.raw.recipe[recipe_name], product, amount)
add_to_product(data.raw.recipe[recipe_name].normal, product, amount)
add_to_product(data.raw.recipe[recipe_name].expensive, product, amount)
end
end
@ -1179,12 +1267,14 @@ function remove_prior_unlocks(tech, recipe)
util.remove_recipe_effect(tech, recipe)
if technology.prerequisites then
for i, prerequisite in pairs(technology.prerequisites) do
-- log("BZZZ removing prior unlocks for " .. tech ..", checking " .. prerequisite) -- Handy Debug :|
if string.sub(prerequisite, 1, 3) ~= 'ei_' then
-- log("BZZZ removing prior unlocks for " .. recipe .. " from " .. tech ..", checking " .. prerequisite) -- Handy Debug :|
remove_prior_unlocks(prerequisite, recipe)
end
end
end
end
end
function util.replace_ingredients_prior_to(tech, old, new, multiplier)
if not data.raw.technology[tech] then
@ -1222,11 +1312,13 @@ function replace_ingredients_prior_to(tech, old, new, multiplier)
if technology.prerequisites then
for i, prerequisite in pairs(technology.prerequisites) do
-- log("BZZZ checking " .. prerequisite) -- Handy Debug :|
if string.sub(prerequisite, 1, 3) ~= 'ei_' then
replace_ingredients_prior_to(prerequisite, old, new, multiplier)
end
end
end
end
end
function util.remove_all_recipe_effects(recipe_name)
for name, _ in pairs(data.raw.technology) do

View file

Before

Width:  |  Height:  |  Size: 1.6 MiB

After

Width:  |  Height:  |  Size: 1.6 MiB

Before After
Before After

Binary file not shown.

After

Width:  |  Height:  |  Size: 608 KiB

Binary file not shown.

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

View file

Before

Width:  |  Height:  |  Size: 21 KiB

After

Width:  |  Height:  |  Size: 21 KiB

Before After
Before After

View file

Before

Width:  |  Height:  |  Size: 14 KiB

After

Width:  |  Height:  |  Size: 14 KiB

Before After
Before After

View file

Before

Width:  |  Height:  |  Size: 14 KiB

After

Width:  |  Height:  |  Size: 14 KiB

Before After
Before After

View file

Before

Width:  |  Height:  |  Size: 14 KiB

After

Width:  |  Height:  |  Size: 14 KiB

Before After
Before After

View file

Before

Width:  |  Height:  |  Size: 14 KiB

After

Width:  |  Height:  |  Size: 14 KiB

Before After
Before After

View file

Before

Width:  |  Height:  |  Size: 13 KiB

After

Width:  |  Height:  |  Size: 13 KiB

Before After
Before After

View file

Before

Width:  |  Height:  |  Size: 4.2 KiB

After

Width:  |  Height:  |  Size: 4.2 KiB

Before After
Before After

View file

Before

Width:  |  Height:  |  Size: 23 KiB

After

Width:  |  Height:  |  Size: 23 KiB

Before After
Before After

View file

Before

Width:  |  Height:  |  Size: 9.6 KiB

After

Width:  |  Height:  |  Size: 9.6 KiB

Before After
Before After

View file

Before

Width:  |  Height:  |  Size: 4.3 KiB

After

Width:  |  Height:  |  Size: 4.3 KiB

Before After
Before After

View file

Before

Width:  |  Height:  |  Size: 23 KiB

After

Width:  |  Height:  |  Size: 23 KiB

Before After
Before After

View file

Before

Width:  |  Height:  |  Size: 16 KiB

After

Width:  |  Height:  |  Size: 16 KiB

Before After
Before After

View file

Before

Width:  |  Height:  |  Size: 24 KiB

After

Width:  |  Height:  |  Size: 24 KiB

Before After
Before After

View file

Before

Width:  |  Height:  |  Size: 12 KiB

After

Width:  |  Height:  |  Size: 12 KiB

Before After
Before After

View file

Before

Width:  |  Height:  |  Size: 16 KiB

After

Width:  |  Height:  |  Size: 16 KiB

Before After
Before After

View file

Before

Width:  |  Height:  |  Size: 11 KiB

After

Width:  |  Height:  |  Size: 11 KiB

Before After
Before After

View file

Before

Width:  |  Height:  |  Size: 13 KiB

After

Width:  |  Height:  |  Size: 13 KiB

Before After
Before After

View file

Before

Width:  |  Height:  |  Size: 12 KiB

After

Width:  |  Height:  |  Size: 12 KiB

Before After
Before After

View file

Before

Width:  |  Height:  |  Size: 11 KiB

After

Width:  |  Height:  |  Size: 11 KiB

Before After
Before After

View file

Before

Width:  |  Height:  |  Size: 13 KiB

After

Width:  |  Height:  |  Size: 13 KiB

Before After
Before After

View file

Before

Width:  |  Height:  |  Size: 9.2 KiB

After

Width:  |  Height:  |  Size: 9.2 KiB

Before After
Before After

View file

Before

Width:  |  Height:  |  Size: 93 KiB

After

Width:  |  Height:  |  Size: 93 KiB

Before After
Before After

View file

@ -1,13 +1,13 @@
{
"name": "bztungsten2",
"version": "2.0.0",
"factorio_version": "2.0",
"name": "bztungsten",
"version": "0.7.11",
"factorio_version": "1.1",
"title": "Tungsten",
"author": "Brevven",
"contact": "",
"homepage": "",
"dependencies": [
"base >= 2.0",
"base >= 1.1.0",
"? space-exploration",
"? Krastorio2",
"? deadlock-beltboxes-loaders",

Some files were not shown because too many files have changed in this diff Show more