Format
This commit is contained in:
parent
e4003fbf91
commit
6c6f53dd2c
1 changed files with 796 additions and 684 deletions
|
|
@ -126,11 +126,16 @@ function should_force(options)
|
|||
return options and options.force
|
||||
end
|
||||
|
||||
|
||||
function bypass(recipe_name)
|
||||
if me.bypass[recipe_name] then return true end
|
||||
if allbypass[recipe_name] then return true end
|
||||
if get_setting("bz-tabula-rasa") then return true end
|
||||
if me.bypass[recipe_name] then
|
||||
return true
|
||||
end
|
||||
if allbypass[recipe_name] then
|
||||
return true
|
||||
end
|
||||
if get_setting("bz-tabula-rasa") then
|
||||
return true
|
||||
end
|
||||
end
|
||||
|
||||
function util.fe_plus(sub)
|
||||
|
|
@ -173,8 +178,12 @@ function util.copy_recipe(recipe_name, new_recipe_name)
|
|||
end
|
||||
|
||||
function util.add_shiftite_recipe(item, shiftites, quantity)
|
||||
if not mods["janus"] then return end
|
||||
if not data.raw.item[item] then return end
|
||||
if not mods["janus"] then
|
||||
return
|
||||
end
|
||||
if not data.raw.item[item] then
|
||||
return
|
||||
end
|
||||
local its = {}
|
||||
for _, shiftite in pairs(shiftites) do
|
||||
local it = "janus-shiftite-" .. shiftite
|
||||
|
|
@ -209,7 +218,9 @@ function util.add_gleba_rock(resource, amount_min, amount_max)
|
|||
not data.raw.planet.gleba.map_gen_settings.autoplace_settings or
|
||||
not data.raw.planet.gleba.map_gen_settings.autoplace_settings.entity or
|
||||
not data.raw.planet.gleba.map_gen_settings.autoplace_settings.entity.settings
|
||||
) then return end
|
||||
) then
|
||||
return
|
||||
end
|
||||
if not data.raw["simple-entity"]["gleba-rock"] then
|
||||
local autoplace_utils = require("autoplace_utils")
|
||||
local hit_effects = require("__base__.prototypes.entity.hit-effects")
|
||||
|
|
@ -250,16 +261,14 @@ function util.add_gleba_rock(resource, amount_min, amount_max)
|
|||
},
|
||||
|
||||
dying_trigger_effect = decorative_trigger_effects.big_rock(),
|
||||
minable =
|
||||
{
|
||||
minable = {
|
||||
mining_particle = "stone-particle",
|
||||
mining_time = 2,
|
||||
results = {
|
||||
{ type = "item", name = "stone", amount_min = 5, amount_max = 10 },
|
||||
}
|
||||
},
|
||||
resistances =
|
||||
{
|
||||
resistances = {
|
||||
{
|
||||
type = "fire",
|
||||
percent = 100
|
||||
|
|
@ -269,8 +278,7 @@ function util.add_gleba_rock(resource, amount_min, amount_max)
|
|||
count_as_rock_for_filtered_deconstruction = true,
|
||||
mined_sound = sounds.deconstruct_bricks(1.0),
|
||||
impact_category = "stone",
|
||||
pictures =
|
||||
{
|
||||
pictures = {
|
||||
{
|
||||
filename = "__base__/graphics/decorative/sand-rock/big-sand-rock-01.png",
|
||||
tint = gleba_tint,
|
||||
|
|
@ -423,26 +431,25 @@ end
|
|||
|
||||
-- Replace 'uranium-mining' tech with 'fluid-mining', defaulting to same costs
|
||||
function util.add_fluid_mining()
|
||||
if data.raw.technology["fluid-mining"] then return end
|
||||
if data.raw.technology["fluid-mining"] then
|
||||
return
|
||||
end
|
||||
data:extend({
|
||||
{
|
||||
type = "technology",
|
||||
name = "fluid-mining",
|
||||
icon = "__" .. util.me.name .. "__/graphics/technology/fluid-mining.png",
|
||||
icon_size = 256,
|
||||
effects =
|
||||
{
|
||||
effects = {
|
||||
{
|
||||
type = "mining-with-fluid",
|
||||
modifier = true
|
||||
}
|
||||
},
|
||||
prerequisites = { "chemical-science-pack", "concrete" },
|
||||
unit =
|
||||
{
|
||||
unit = {
|
||||
count = 100,
|
||||
ingredients =
|
||||
{
|
||||
ingredients = {
|
||||
{ "automation-science-pack", 1 },
|
||||
{ "logistic-science-pack", 1 },
|
||||
{ "chemical-science-pack", 1 }
|
||||
|
|
@ -509,7 +516,9 @@ end
|
|||
-- params: ore, icon_size
|
||||
function util.se_landfill(params)
|
||||
if mods["space-exploration"] then
|
||||
if not params.icon_size then params.icon_size = 64 end
|
||||
if not params.icon_size then
|
||||
params.icon_size = 64
|
||||
end
|
||||
local lname = "landfill-" .. params.ore
|
||||
data:extend({
|
||||
{
|
||||
|
|
@ -558,8 +567,7 @@ function util.k2matter(params)
|
|||
{
|
||||
type = "technology",
|
||||
name = params.k2matter.unlocked_by,
|
||||
icons =
|
||||
{
|
||||
icons = {
|
||||
{
|
||||
icon = icon,
|
||||
icon_size = 256,
|
||||
|
|
@ -567,8 +575,7 @@ function util.k2matter(params)
|
|||
params.icon,
|
||||
},
|
||||
prerequisites = { "kr-matter-processing" },
|
||||
unit =
|
||||
{
|
||||
unit = {
|
||||
count = 350,
|
||||
ingredients = mods["space-exploration"] and
|
||||
{
|
||||
|
|
@ -604,8 +611,12 @@ end
|
|||
-- se matter
|
||||
-- params: ore, energy_required, quant_out, quant_in, icon_size, stream_out
|
||||
function util.se_matter(params)
|
||||
if not params.quant_in then params.quant_in = params.quant_out end
|
||||
if not params.icon_size then params.icon_size = 64 end
|
||||
if not params.quant_in then
|
||||
params.quant_in = params.quant_out
|
||||
end
|
||||
if not params.icon_size then
|
||||
params.icon_size = 64
|
||||
end
|
||||
local fname = "matter-fusion-" .. params.ore
|
||||
local sedata = util.k2() and "se-kr-matter-synthesis-data" or "se-fusion-test-data"
|
||||
local sejunk = util.k2() and "se-broken-data" or "se-junk-data"
|
||||
|
|
@ -744,7 +755,9 @@ function util.add_prerequisite(technology_name, prerequisite)
|
|||
if technology and data.raw.technology[prerequisite] then
|
||||
if technology.prerequisites then
|
||||
for i, pre in pairs(technology.prerequisites) do
|
||||
if pre == prerequisite then return end
|
||||
if pre == prerequisite then
|
||||
return
|
||||
end
|
||||
end
|
||||
table.insert(technology.prerequisites, prerequisite)
|
||||
else
|
||||
|
|
@ -775,7 +788,9 @@ end
|
|||
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 not technology.effects then
|
||||
technology.effects = {}
|
||||
end
|
||||
if effect and effect.type == "unlock-recipe" then
|
||||
if not data.raw.recipe[effect.recipe] then
|
||||
return
|
||||
|
|
@ -787,7 +802,9 @@ end
|
|||
|
||||
-- Make a technology boost productivity for a recipe
|
||||
function util.add_to_productivity_research(technology_name, recipe_name, amount)
|
||||
if not amount then amount = 0.1 end
|
||||
if not amount then
|
||||
amount = 0.1
|
||||
end
|
||||
local recipe = data.raw.recipe[recipe_name]
|
||||
if recipe then
|
||||
util.add_effect(technology_name, { type = "change-recipe-productivity", recipe = recipe_name, change = amount })
|
||||
|
|
@ -828,7 +845,8 @@ function util.remove_recipe_effect(technology_name, recipe_name)
|
|||
end
|
||||
if index > -1 then
|
||||
table.remove(technology.effects, index)
|
||||
if cnt > 1 then -- not over yet, do it again
|
||||
if cnt > 1 then
|
||||
-- not over yet, do it again
|
||||
util.remove_recipe_effect(technology_name, recipe_name)
|
||||
end
|
||||
end
|
||||
|
|
@ -889,7 +907,9 @@ end
|
|||
|
||||
-- Add a given quantity of ingredient to a given recipe
|
||||
function util.add_or_add_to_ingredient(recipe_name, ingredient, quantity, options)
|
||||
if not should_force(options) and bypass(recipe_name) then return end
|
||||
if not should_force(options) and bypass(recipe_name) then
|
||||
return
|
||||
end
|
||||
if data.raw.recipe[recipe_name] and util.get_item(ingredient) then
|
||||
me.add_modified(recipe_name)
|
||||
prepare_redo_recycling(recipe_name)
|
||||
|
|
@ -910,18 +930,30 @@ function add_or_add_to_ingredient(recipe, ingredient, quantity)
|
|||
end
|
||||
|
||||
function util.get_item(name)
|
||||
if data.raw.item[name] then return data.raw.item[name] end
|
||||
if data.raw.armor[name] then return data.raw.armor[name] end
|
||||
if data.raw.fluid[name] then return data.raw.fluid[name] end
|
||||
if data.raw.capsule[name] then return data.raw.capsule[name] end
|
||||
if data.raw["space-platform-starter-pack"] and data.raw["space-platform-starter-pack"][name] then return data.raw["space-platform-starter-pack"][name] end
|
||||
if data.raw.item[name] then
|
||||
return data.raw.item[name]
|
||||
end
|
||||
if data.raw.armor[name] then
|
||||
return data.raw.armor[name]
|
||||
end
|
||||
if data.raw.fluid[name] then
|
||||
return data.raw.fluid[name]
|
||||
end
|
||||
if data.raw.capsule[name] then
|
||||
return data.raw.capsule[name]
|
||||
end
|
||||
if data.raw["space-platform-starter-pack"] and data.raw["space-platform-starter-pack"][name] then
|
||||
return data.raw["space-platform-starter-pack"][name]
|
||||
end
|
||||
-- TODO add more subtypes of item here
|
||||
return nil
|
||||
end
|
||||
|
||||
-- Add a given quantity of ingredient to a given recipe
|
||||
function util.add_ingredient(recipe_name, ingredient, quantity, options)
|
||||
if not should_force(options) and bypass(recipe_name) then return end
|
||||
if not should_force(options) and bypass(recipe_name) then
|
||||
return
|
||||
end
|
||||
local is_fluid = not not data.raw.fluid[ingredient]
|
||||
if data.raw.recipe[recipe_name] and (util.get_item(ingredient) or is_fluid) then
|
||||
me.add_modified(recipe_name)
|
||||
|
|
@ -947,7 +979,9 @@ end
|
|||
|
||||
-- Add a given ingredient prototype to a given recipe
|
||||
function util.add_ingredient_raw(recipe_name, ingredient, options)
|
||||
if not should_force(options) and bypass(recipe_name) then return end
|
||||
if not should_force(options) and bypass(recipe_name) then
|
||||
return
|
||||
end
|
||||
if data.raw.recipe[recipe_name] and data.raw.item[ingredient.name] then
|
||||
me.add_modified(recipe_name)
|
||||
prepare_redo_recycling(recipe_name)
|
||||
|
|
@ -968,7 +1002,9 @@ end
|
|||
|
||||
-- Set an ingredient to a given quantity
|
||||
function util.set_ingredient(recipe_name, ingredient, quantity, options)
|
||||
if not should_force(options) and bypass(recipe_name) then return end
|
||||
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)
|
||||
|
|
@ -997,7 +1033,9 @@ 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, options)
|
||||
if not should_force(options) and bypass(recipe_name) then return end
|
||||
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
|
||||
add_product(data.raw.recipe[recipe_name], product)
|
||||
|
|
@ -1026,7 +1064,9 @@ function util.get_ingredient_amount(recipe_name, ingredient_name)
|
|||
if recipe then
|
||||
if recipe.ingredients then
|
||||
for i, ingredient in pairs(recipe.ingredients) do
|
||||
if ingredient.name == ingredient_name then return ingredient.amount end
|
||||
if ingredient.name == ingredient_name then
|
||||
return ingredient.amount
|
||||
end
|
||||
end
|
||||
end
|
||||
return 0
|
||||
|
|
@ -1036,7 +1076,9 @@ end
|
|||
|
||||
-- Get the amount of the result (currently ignores probability)
|
||||
function util.get_amount(recipe_name, product)
|
||||
if not product then product = recipe_name end
|
||||
if not product then
|
||||
product = recipe_name
|
||||
end
|
||||
local recipe = data.raw.recipe[recipe_name]
|
||||
if recipe then
|
||||
if recipe.results then
|
||||
|
|
@ -1057,7 +1099,9 @@ end
|
|||
|
||||
-- Get the count of results
|
||||
function util.get_result_count(recipe_name, product)
|
||||
if not product then product = recipe_name end
|
||||
if not product then
|
||||
product = recipe_name
|
||||
end
|
||||
local recipe = data.raw.recipe[recipe_name]
|
||||
if recipe then
|
||||
if recipe.results then
|
||||
|
|
@ -1071,7 +1115,9 @@ end
|
|||
-- Replace one ingredient with another in a recipe
|
||||
-- Use amount to set an amount. If that amount is a multiplier instead of an exact amount, set multiply true.
|
||||
function util.replace_ingredient(recipe_name, old, new, amount, multiply, options)
|
||||
if not should_force(options) and bypass(recipe_name) then return end
|
||||
if not should_force(options) and bypass(recipe_name) then
|
||||
return
|
||||
end
|
||||
if data.raw.recipe[recipe_name] and (data.raw.item[new] or data.raw.fluid[new]) and (data.raw.item[old] or data.raw.fluid[old]) then
|
||||
me.add_modified(recipe_name)
|
||||
prepare_redo_recycling(recipe_name)
|
||||
|
|
@ -1103,7 +1149,9 @@ end
|
|||
|
||||
-- Remove an ingredient from a recipe
|
||||
function util.remove_ingredient(recipe_name, old, options)
|
||||
if not should_force(options) and bypass(recipe_name) then return end
|
||||
if not should_force(options) and bypass(recipe_name) then
|
||||
return
|
||||
end
|
||||
if data.raw.recipe[recipe_name] then
|
||||
me.add_modified(recipe_name)
|
||||
prepare_redo_recycling(recipe_name)
|
||||
|
|
@ -1128,7 +1176,9 @@ end
|
|||
|
||||
-- Replace an amount of a product, leaving at least 1 of old
|
||||
function util.replace_some_product(recipe_name, old, old_amount, new, new_amount, options)
|
||||
if not should_force(options) and bypass(recipe_name) then return end
|
||||
if not should_force(options) and bypass(recipe_name) then
|
||||
return
|
||||
end
|
||||
local is_fluid = not not data.raw.fluid[new] -- NOTE CURRENTLY UNUSUED
|
||||
if data.raw.recipe[recipe_name] and (data.raw.item[new] or is_fluid) then
|
||||
me.add_modified(recipe_name)
|
||||
|
|
@ -1139,7 +1189,9 @@ end
|
|||
|
||||
function replace_some_product(recipe, old, old_amount, new, new_amount, is_fluid)
|
||||
if recipe ~= nil then
|
||||
if recipe.result == new then return end
|
||||
if recipe.result == new then
|
||||
return
|
||||
end
|
||||
if recipe.results then
|
||||
for i, existing in pairs(recipe.results) do
|
||||
if existing.name == new then
|
||||
|
|
@ -1158,7 +1210,9 @@ 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, options)
|
||||
if not should_force(options) and bypass(recipe_name) then return end
|
||||
if not should_force(options) and 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)
|
||||
|
|
@ -1185,7 +1239,9 @@ end
|
|||
|
||||
-- set the probability of a product.
|
||||
function util.set_product_probability(recipe_name, product, probability, options)
|
||||
if not should_force(options) and bypass(recipe_name) then return end
|
||||
if not should_force(options) and bypass(recipe_name) then
|
||||
return
|
||||
end
|
||||
if data.raw.recipe[recipe_name] then
|
||||
me.add_modified(recipe_name)
|
||||
prepare_redo_recycling(recipe_name)
|
||||
|
|
@ -1207,7 +1263,9 @@ end
|
|||
|
||||
-- set the amount of a product.
|
||||
function util.set_product_amount(recipe_name, product, amount, options)
|
||||
if not should_force(options) and bypass(recipe_name) then return end
|
||||
if not should_force(options) and bypass(recipe_name) then
|
||||
return
|
||||
end
|
||||
if data.raw.recipe[recipe_name] then
|
||||
me.add_modified(recipe_name)
|
||||
prepare_redo_recycling(recipe_name)
|
||||
|
|
@ -1236,7 +1294,9 @@ end
|
|||
|
||||
-- multiply the cost, energy, and results of a recipe by a multiple
|
||||
function util.multiply_recipe(recipe_name, multiple, options)
|
||||
if not should_force(options) and bypass(recipe_name) then return end
|
||||
if not should_force(options) and bypass(recipe_name) then
|
||||
return
|
||||
end
|
||||
if data.raw.recipe[recipe_name] then
|
||||
me.add_modified(recipe_name)
|
||||
prepare_redo_recycling(recipe_name)
|
||||
|
|
@ -1276,7 +1336,9 @@ end
|
|||
|
||||
-- multiply the ingredient cost of a recipe
|
||||
function util.multiply_ingredients(recipe_name, multiple, options)
|
||||
if not should_force(options) and bypass(recipe_name) then return end
|
||||
if not should_force(options) and bypass(recipe_name) then
|
||||
return
|
||||
end
|
||||
if data.raw.recipe[recipe_name] then
|
||||
me.add_modified(recipe_name)
|
||||
prepare_redo_recycling(recipe_name)
|
||||
|
|
@ -1315,7 +1377,9 @@ end
|
|||
|
||||
-- Remove a product from a recipe, WILL NOT remove the only product
|
||||
function util.remove_product(recipe_name, old, options)
|
||||
if not should_force(options) and bypass(recipe_name) then return end
|
||||
if not should_force(options) and bypass(recipe_name) then
|
||||
return
|
||||
end
|
||||
if data.raw.recipe[recipe_name] then
|
||||
me.add_modified(recipe_name)
|
||||
prepare_redo_recycling(recipe_name)
|
||||
|
|
@ -1339,7 +1403,9 @@ function remove_product(recipe, old)
|
|||
end
|
||||
|
||||
function util.set_main_product(recipe_name, product, options)
|
||||
if not should_force(options) and bypass(recipe_name) then return end
|
||||
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)
|
||||
end
|
||||
|
|
@ -1353,7 +1419,9 @@ end
|
|||
|
||||
-- Replace one product with another in a recipe
|
||||
function util.replace_product(recipe_name, old, new, options)
|
||||
if not should_force(options) and bypass(recipe_name) then return end
|
||||
if not should_force(options) and bypass(recipe_name) then
|
||||
return
|
||||
end
|
||||
if data.raw.recipe[recipe_name] and (data.raw.item[new] or data.raw.fluid[new]) then
|
||||
replace_product(data.raw.recipe[recipe_name], old, new, options)
|
||||
end
|
||||
|
|
@ -1366,7 +1434,9 @@ function replace_product(recipe, old, new, options)
|
|||
end
|
||||
if recipe.results then
|
||||
for i, result in pairs(recipe.results) do
|
||||
if result.name == old then result.name = new end
|
||||
if result.name == old then
|
||||
result.name = new
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
@ -1390,7 +1460,9 @@ end
|
|||
|
||||
-- Set energy required
|
||||
function util.set_recipe_time(recipe_name, time, options)
|
||||
if not should_force(options) and bypass(recipe_name) then return end
|
||||
if not should_force(options) and bypass(recipe_name) then
|
||||
return
|
||||
end
|
||||
if data.raw.recipe[recipe_name] then
|
||||
me.add_modified(recipe_name)
|
||||
prepare_redo_recycling(recipe_name)
|
||||
|
|
@ -1408,7 +1480,9 @@ end
|
|||
|
||||
-- Multiply energy required
|
||||
function util.multiply_time(recipe_name, factor, options)
|
||||
if not should_force(options) and bypass(recipe_name) then return end
|
||||
if not should_force(options) and bypass(recipe_name) then
|
||||
return
|
||||
end
|
||||
if data.raw.recipe[recipe_name] then
|
||||
me.add_modified(recipe_name)
|
||||
prepare_redo_recycling(recipe_name)
|
||||
|
|
@ -1426,7 +1500,9 @@ end
|
|||
|
||||
-- Add to energy required
|
||||
function util.add_time(recipe_name, amount, options)
|
||||
if not should_force(options) and bypass(recipe_name) then return end
|
||||
if not should_force(options) and bypass(recipe_name) then
|
||||
return
|
||||
end
|
||||
if data.raw.recipe[recipe_name] then
|
||||
me.add_modified(recipe_name)
|
||||
prepare_redo_recycling(recipe_name)
|
||||
|
|
@ -1451,7 +1527,9 @@ end
|
|||
|
||||
-- Set recipe category
|
||||
function util.set_category(recipe_name, category, options)
|
||||
if not should_force(options) and bypass(recipe_name) then return end
|
||||
if not should_force(options) and bypass(recipe_name) then
|
||||
return
|
||||
end
|
||||
if data.raw.recipe[recipe_name] and data.raw["recipe-category"][category] then
|
||||
me.add_modified(recipe_name)
|
||||
prepare_redo_recycling(recipe_name)
|
||||
|
|
@ -1461,7 +1539,9 @@ 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 not should_force(options) and bypass(recipe_name) then
|
||||
return
|
||||
end
|
||||
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
|
||||
|
|
@ -1470,14 +1550,18 @@ end
|
|||
|
||||
-- Set item subgroup
|
||||
function util.set_item_subgroup(item, subgroup, options)
|
||||
if not should_force(options) and bypass(item) then return end -- imperfect, close enough for now?
|
||||
if not should_force(options) and bypass(item) then
|
||||
return
|
||||
end -- imperfect, close enough for now?
|
||||
if data.raw.item[item] and data.raw["item-subgroup"][subgroup] then
|
||||
data.raw.item[item].subgroup = subgroup
|
||||
end
|
||||
end
|
||||
|
||||
function util.add_icon(recipe_name, icon, options)
|
||||
if not should_force(options) and bypass(recipe_name) then return end
|
||||
if not should_force(options) and bypass(recipe_name) then
|
||||
return
|
||||
end
|
||||
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
|
||||
|
|
@ -1509,7 +1593,9 @@ end
|
|||
|
||||
-- Set recipe icons
|
||||
function util.set_icons(recipe_name, icons, options)
|
||||
if not should_force(options) and bypass(recipe_name) then return end
|
||||
if not should_force(options) and 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
|
||||
|
|
@ -1520,7 +1606,9 @@ end
|
|||
|
||||
-- Set tech icons
|
||||
function util.set_tech_icons(technology, icons, options)
|
||||
if not should_force(options) and bypass(technology) then return end
|
||||
if not should_force(options) and bypass(technology) then
|
||||
return
|
||||
end
|
||||
if data.raw.technology[technology] then
|
||||
me.add_modified(technology)
|
||||
data.raw.technology[technology].icons = icons
|
||||
|
|
@ -1543,10 +1631,14 @@ function util.get_item_or_fluid_icon(name)
|
|||
icon = ""
|
||||
if data.raw.item[name] then
|
||||
icon = data.raw.item[name].icon
|
||||
if not icon then icon = data.raw.item[name].icons[1].icon end
|
||||
if not icon then
|
||||
icon = data.raw.item[name].icons[1].icon
|
||||
end
|
||||
elseif data.raw.fluid[name] then
|
||||
icon = data.raw.fluid[name].icon
|
||||
if not icon then icon = data.raw.fluid[name].icons[1].icon end
|
||||
if not icon then
|
||||
icon = data.raw.fluid[name].icons[1].icon
|
||||
end
|
||||
end
|
||||
return icon
|
||||
end
|
||||
|
|
@ -1595,9 +1687,10 @@ function util.add_crafting_category_if(entity_type, category, other_category)
|
|||
end
|
||||
end
|
||||
|
||||
|
||||
function util.add_to_ingredient(recipe, ingredient, amount, options)
|
||||
if not should_force(options) and bypass(recipe_name) then return end
|
||||
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)
|
||||
end
|
||||
|
|
@ -1615,7 +1708,9 @@ function add_to_ingredient(recipe, it, amount)
|
|||
end
|
||||
|
||||
function util.add_to_product(recipe_name, product, amount, options)
|
||||
if not should_force(options) and bypass(recipe_name) then return end
|
||||
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)
|
||||
end
|
||||
|
|
@ -1643,7 +1738,9 @@ function util.add_minable_result(t, name, result)
|
|||
end
|
||||
if data.raw[t][name].minable.results then
|
||||
for _, other in pairs(data.raw[t][name].minable.results) do
|
||||
if other.name == result.name then return end -- don't add if already present
|
||||
if other.name == result.name then
|
||||
return
|
||||
end -- don't add if already present
|
||||
end
|
||||
table.insert(data.raw[t][name].minable.results, result)
|
||||
else
|
||||
|
|
@ -1653,7 +1750,9 @@ function util.add_minable_result(t, name, result)
|
|||
end
|
||||
|
||||
function util.set_surface_property(surface, condition, value)
|
||||
if not data.raw["surface-property"][condition] then return end
|
||||
if not data.raw["surface-property"][condition] then
|
||||
return
|
||||
end
|
||||
if data.raw.surface[surface] then
|
||||
data.raw.surface[surface].surface_properties[condition] = value
|
||||
end
|
||||
|
|
@ -1662,7 +1761,6 @@ function util.set_surface_property(surface, condition, value)
|
|||
end
|
||||
end
|
||||
|
||||
|
||||
local function insert(nodes, node, value)
|
||||
table.insert(node, value) -- store as parameter
|
||||
if 21 == #node then
|
||||
|
|
@ -1687,14 +1785,18 @@ local function encode(data)
|
|||
end
|
||||
root = nodes
|
||||
end
|
||||
if #root == 1 then root = root[1] else
|
||||
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
|
||||
if type(data) == "string" then
|
||||
return data
|
||||
end
|
||||
local str = {}
|
||||
for i = 2, #data do
|
||||
str[i - 1] = decode(data[i])
|
||||
|
|
@ -1729,8 +1831,7 @@ function util.create_list()
|
|||
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"))
|
||||
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
|
||||
|
|
@ -1831,15 +1932,22 @@ function util.sum_products(recipe_name)
|
|||
-- this is going to end up approximate in some cases, integer division is probs fine
|
||||
if data.raw.recipe[recipe_name] then
|
||||
local recipe = data.raw.recipe[recipe_name]
|
||||
if not recipe.results then return recipe.result_count end
|
||||
if not recipe.results then
|
||||
return recipe.result_count
|
||||
end
|
||||
local sum = 0
|
||||
for i, result in pairs(recipe.results) do
|
||||
local amt = 0
|
||||
if result[2] then amt = result[2]
|
||||
elseif result.amount then amt = result.amount
|
||||
elseif result.amount_min then amt = (result.amount_min + result.amount_max)/2
|
||||
if result[2] then
|
||||
amt = result[2]
|
||||
elseif result.amount then
|
||||
amt = result.amount
|
||||
elseif result.amount_min then
|
||||
amt = (result.amount_min + result.amount_max) / 2
|
||||
end
|
||||
if result.probability then
|
||||
amt = amt * result.probability
|
||||
end
|
||||
if result.probability then amt = amt * result.probability end
|
||||
sum = sum + amt
|
||||
end
|
||||
return sum
|
||||
|
|
@ -1956,7 +2064,8 @@ end
|
|||
-- 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.
|
||||
function util.addtype(name,atint,desc) --,pictures)
|
||||
function util.addtype(name, atint, desc)
|
||||
--,pictures)
|
||||
require("__Asteroid_Mining__/scripts/icons.lua") -- Has generateicons function
|
||||
|
||||
local allowprod = settings.startup["astmine-allowprod"].value
|
||||
|
|
@ -1971,7 +2080,8 @@ function util.addtype(name,atint,desc) --,pictures)
|
|||
|
||||
--Adds given recipe to prod modules allowed list
|
||||
function addmodules(name)
|
||||
if useminer then -- Only add these if we're actually enabled.
|
||||
if useminer then
|
||||
-- Only add these if we're actually enabled.
|
||||
table.insert(data.raw.module["productivity-module"].limitation, name)
|
||||
table.insert(data.raw.module["productivity-module-2"].limitation, name)
|
||||
table.insert(data.raw.module["productivity-module-3"].limitation, name)
|
||||
|
|
@ -2162,7 +2272,8 @@ function util.addtype(name,atint,desc) --,pictures)
|
|||
type = "recipe"
|
||||
}
|
||||
data:extend { reschunk, procreschunk, newasteroid, processasteroid }
|
||||
if useminer then -- Disabled in 1.0 for the new generation system, once in place.
|
||||
if useminer then
|
||||
-- Disabled in 1.0 for the new generation system, once in place.
|
||||
data:extend { minerres, newminer }
|
||||
--This makes the miner module available when rocket silo is researched
|
||||
table.insert(data.raw.technology["rocket-silo"].effects, { type = "unlock-recipe", recipe = "miner-module-" .. name })
|
||||
|
|
@ -2171,7 +2282,8 @@ function util.addtype(name,atint,desc) --,pictures)
|
|||
table.insert(data.raw.technology["rocket-silo"].effects, { type = "unlock-recipe", recipe = name .. suffix })
|
||||
end
|
||||
end
|
||||
if allowprod then -- Setting to enable prod module usage in asteroid processing
|
||||
if allowprod then
|
||||
-- Setting to enable prod module usage in asteroid processing
|
||||
addmodules(processasteroid.name)
|
||||
end
|
||||
end
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue