some fixes, compat
This commit is contained in:
parent
cb82b58b39
commit
1fd1eb7e06
5 changed files with 86 additions and 26 deletions
|
|
@ -1,4 +1,9 @@
|
||||||
---------------------------------------------------------------------------------------------------
|
---------------------------------------------------------------------------------------------------
|
||||||
|
Version: 2.1.2
|
||||||
|
Date: 2025-02-01
|
||||||
|
Changes:
|
||||||
|
- Add shiftite recipe for Janus mod
|
||||||
|
---------------------------------------------------------------------------------------------------
|
||||||
Version: 2.1.1
|
Version: 2.1.1
|
||||||
Date: 2025-01-25
|
Date: 2025-01-25
|
||||||
Fixes:
|
Fixes:
|
||||||
|
|
|
||||||
|
|
@ -58,8 +58,17 @@ function list(event)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
function util.add_command_handler()
|
||||||
|
script.on_event(defines.events.on_console_command, route)
|
||||||
|
end
|
||||||
|
|
||||||
|
function route(event)
|
||||||
|
if event.command == regenerate_command then regenerate_ore(event) end
|
||||||
|
if event.command == list_command then list(event) end
|
||||||
|
end
|
||||||
|
|
||||||
function util.add_list_command_handler()
|
function util.add_list_command_handler()
|
||||||
script.on_event(defines.events.on_console_command, list)
|
util.add_command_handler()
|
||||||
|
|
||||||
if not commands.commands[list_command] then
|
if not commands.commands[list_command] then
|
||||||
commands.add_command(list_command, "", function() end)
|
commands.add_command(list_command, "", function() end)
|
||||||
|
|
@ -134,7 +143,7 @@ Regenerates ore patches. If frequency/size/richness are provided, the planet wil
|
||||||
- Ores can sometimes overlap on regeneration. This can sometimes hide ore patches. If none seem to be made for a resource, regenerate just that resource and tweak frequency/size.
|
- Ores can sometimes overlap on regeneration. This can sometimes hide ore patches. If none seem to be made for a resource, regenerate just that resource and tweak frequency/size.
|
||||||
]]
|
]]
|
||||||
function util.add_regenerate_command_handler()
|
function util.add_regenerate_command_handler()
|
||||||
script.on_event(defines.events.on_console_command, regenerate_ore)
|
util.add_command_handler()
|
||||||
|
|
||||||
if not commands.commands[regenerate_command] then
|
if not commands.commands[regenerate_command] then
|
||||||
commands.add_command( regenerate_command, usage_regenerate, function() end)
|
commands.add_command( regenerate_command, usage_regenerate, function() end)
|
||||||
|
|
@ -147,9 +156,9 @@ function regenerate_ore(event)
|
||||||
for w in event.parameters:gmatch("%S+") do table.insert(params, w) end
|
for w in event.parameters:gmatch("%S+") do table.insert(params, w) end
|
||||||
if #params == 1 and params[1] == "all" then
|
if #params == 1 and params[1] == "all" then
|
||||||
for _, resource in pairs(me.resources) do
|
for _, resource in pairs(me.resources) do
|
||||||
if prototypes.entity[resource] then
|
if prototypes.entity[resource[1]] then
|
||||||
game.print("Regenerating "..resource)
|
game.print("Regenerating "..resource[1])
|
||||||
game.regenerate_entity(resource)
|
game.regenerate_entity(resource[1])
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
return
|
return
|
||||||
|
|
@ -164,17 +173,17 @@ function regenerate_ore(event)
|
||||||
game.print("Could not find surface for "..planet..". May not exist, or may not yet be explored.")
|
game.print("Could not find surface for "..planet..". May not exist, or may not yet be explored.")
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
if resource == params[2] then
|
if resource[1] == params[2] and (resource[2] == planet or "tenebris" == planet) then
|
||||||
if #params == 5 then
|
if #params == 5 then
|
||||||
local settings = {frequency=params[3], size=params[4], richness=params[5]}
|
local settings = {frequency=params[3], size=params[4], richness=params[5]}
|
||||||
local map_gen_settings = game.surfaces[planet].map_gen_settings
|
local map_gen_settings = game.surfaces[planet].map_gen_settings
|
||||||
map_gen_settings.autoplace_controls[resource] = settings
|
map_gen_settings.autoplace_controls[resource[1]] = settings
|
||||||
map_gen_settings.autoplace_settings.entity.settings[resource] = settings
|
map_gen_settings.autoplace_settings.entity.settings[resource[1]] = settings
|
||||||
game.surfaces[planet].map_gen_settings = map_gen_settings
|
game.surfaces[planet].map_gen_settings = map_gen_settings
|
||||||
game.print("Set "..resource.." on "..planet.." to "..serpent.line(settings))
|
game.print("Set "..resource[1].." on "..planet.." to "..serpent.line(settings))
|
||||||
end
|
end
|
||||||
game.print("Regenerating "..resource)
|
game.print("Regenerating "..resource[1])
|
||||||
game.surfaces[planet].regenerate_entity(resource)
|
game.surfaces[planet].regenerate_entity(resource[1])
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
@ -182,6 +191,7 @@ end
|
||||||
|
|
||||||
function util.ore_fix()
|
function util.ore_fix()
|
||||||
ore_fix("nauvis")
|
ore_fix("nauvis")
|
||||||
|
ore_fix("vulcanus")
|
||||||
if game.surfaces.tenebris then
|
if game.surfaces.tenebris then
|
||||||
ore_fix("tenebris")
|
ore_fix("tenebris")
|
||||||
end
|
end
|
||||||
|
|
@ -189,16 +199,20 @@ end
|
||||||
|
|
||||||
function ore_fix(surface_name)
|
function ore_fix(surface_name)
|
||||||
for _, resource in pairs(me.resources) do
|
for _, resource in pairs(me.resources) do
|
||||||
|
if resource[2] == surface_name then
|
||||||
|
if game.surfaces[resource[2]] then
|
||||||
local map_gen_settings = game.surfaces[surface_name].map_gen_settings
|
local map_gen_settings = game.surfaces[surface_name].map_gen_settings
|
||||||
if map_gen_settings.autoplace_controls[resource] == nil then
|
if map_gen_settings.autoplace_controls[resource[1]] == nil then
|
||||||
map_gen_settings.autoplace_controls[resource] = {}
|
map_gen_settings.autoplace_controls[resource[1]] = {}
|
||||||
end
|
end
|
||||||
if map_gen_settings.autoplace_settings.entity.settings[resource] == nil then
|
if map_gen_settings.autoplace_settings.entity.settings[resource[1]] == nil then
|
||||||
map_gen_settings.autoplace_settings.entity.settings[resource] = {}
|
map_gen_settings.autoplace_settings.entity.settings[resource[1]] = {}
|
||||||
end
|
end
|
||||||
game.surfaces[surface_name].map_gen_settings = map_gen_settings
|
game.surfaces[surface_name].map_gen_settings = map_gen_settings
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
-- A workaround for generating ores until this bug is fixed:
|
-- A workaround for generating ores until this bug is fixed:
|
||||||
|
|
|
||||||
|
|
@ -23,3 +23,5 @@ if mods["any-planet-start"] then
|
||||||
util.set_prerequisite("zirconia-processing", {"logistic-science-pack"})
|
util.set_prerequisite("zirconia-processing", {"logistic-science-pack"})
|
||||||
end
|
end
|
||||||
util.redo_recycling()
|
util.redo_recycling()
|
||||||
|
|
||||||
|
util.add_shiftite_recipe("zirconia", {"gamma"}, 1)
|
||||||
|
|
|
||||||
|
|
@ -127,6 +127,35 @@ function util.copy_recipe(recipe_name, new_recipe_name)
|
||||||
end
|
end
|
||||||
end
|
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
|
||||||
|
local its = {}
|
||||||
|
for _, shiftite in pairs(shiftites) do
|
||||||
|
local it = "janus-shiftite-"..shiftite
|
||||||
|
if data.raw.item[it] then
|
||||||
|
table.insert(its, util.item(it, quantity))
|
||||||
|
end
|
||||||
|
end
|
||||||
|
if its then
|
||||||
|
local name = "shiftite-to-"..item
|
||||||
|
data:extend({{
|
||||||
|
type = "recipe",
|
||||||
|
name = name,
|
||||||
|
localised_name = {"", {"item-name."..item}, " ← Shiftite"},
|
||||||
|
category = "janus-shiftite",
|
||||||
|
subgroup = "janus-basic-from-shiftite",
|
||||||
|
ingredients = its,
|
||||||
|
results = {util.item(item, 5)},
|
||||||
|
energy_required = 2.5,
|
||||||
|
order = "zzz",
|
||||||
|
enabled = false,
|
||||||
|
auto_recycle = false,
|
||||||
|
}})
|
||||||
|
util.add_unlock("janus-time-distorter", name)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
-- Add the gleba rock. If it exists, still add resource to mine from it
|
-- Add the gleba rock. If it exists, still add resource to mine from it
|
||||||
function util.add_gleba_rock(resource, amount_min, amount_max)
|
function util.add_gleba_rock(resource, amount_min, amount_max)
|
||||||
if (not data.raw.planet.gleba or
|
if (not data.raw.planet.gleba or
|
||||||
|
|
@ -785,7 +814,7 @@ end
|
||||||
-- Add a given quantity of ingredient to a given recipe
|
-- Add a given quantity of ingredient to a given recipe
|
||||||
function util.add_or_add_to_ingredient(recipe_name, ingredient, quantity, options)
|
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 data.raw.item[ingredient] then
|
if data.raw.recipe[recipe_name] and util.get_item(ingredient) then
|
||||||
me.add_modified(recipe_name)
|
me.add_modified(recipe_name)
|
||||||
prepare_redo_recycling(recipe_name)
|
prepare_redo_recycling(recipe_name)
|
||||||
add_or_add_to_ingredient(data.raw.recipe[recipe_name], ingredient, quantity)
|
add_or_add_to_ingredient(data.raw.recipe[recipe_name], ingredient, quantity)
|
||||||
|
|
@ -800,13 +829,15 @@ function add_or_add_to_ingredient(recipe, ingredient, quantity)
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
table.insert(recipe.ingredients, {ingredient, quantity})
|
table.insert(recipe.ingredients, util.item(ingredient, quantity))
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
function util.get_item(name)
|
function util.get_item(name)
|
||||||
if data.raw.item[name] then return data.raw.item[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.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["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
|
-- TODO add more subtypes of item here
|
||||||
return nil
|
return nil
|
||||||
|
|
@ -1489,15 +1520,11 @@ function util.add_to_ingredient(recipe, ingredient, amount, options)
|
||||||
end
|
end
|
||||||
|
|
||||||
function add_to_ingredient(recipe, it, amount)
|
function add_to_ingredient(recipe, it, amount)
|
||||||
if recipe ~= nil and recipe.ingredients ~= nil then
|
if recipe and recipe.ingredients then
|
||||||
for i, ingredient in pairs(recipe.ingredients) do
|
for i, ingredient in pairs(recipe.ingredients) do
|
||||||
if ingredient.name == it then
|
if ingredient.name == it then
|
||||||
ingredient.amount = ingredient.amount + amount
|
ingredient.amount = ingredient.amount + amount
|
||||||
return
|
return
|
||||||
end
|
|
||||||
if ingredient[1] == it then
|
|
||||||
ingredient[2] = ingredient[2] + amount
|
|
||||||
return
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
@ -1545,6 +1572,16 @@ function util.add_minable_result(t, name, result)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
function util.set_surface_property(surface, condition, value)
|
||||||
|
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
|
||||||
|
if data.raw.planet[surface] then
|
||||||
|
data.raw.planet[surface].surface_properties[condition] = value
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
local function insert(nodes, node, value)
|
local function insert(nodes, node, value)
|
||||||
table.insert(node, value) -- store as parameter
|
table.insert(node, value) -- store as parameter
|
||||||
|
|
@ -1629,6 +1666,7 @@ end
|
||||||
function remove_prior_unlocks(tech, recipe)
|
function remove_prior_unlocks(tech, recipe)
|
||||||
local technology = data.raw.technology[tech]
|
local technology = data.raw.technology[tech]
|
||||||
if technology then
|
if technology then
|
||||||
|
log("Removing prior unlocks for ".. tech)
|
||||||
util.remove_recipe_effect(tech, recipe)
|
util.remove_recipe_effect(tech, recipe)
|
||||||
if technology.prerequisites then
|
if technology.prerequisites then
|
||||||
for i, prerequisite in pairs(technology.prerequisites) do
|
for i, prerequisite in pairs(technology.prerequisites) do
|
||||||
|
|
@ -1664,6 +1702,7 @@ function util.replace_ingredients_prior_to(tech, old, new, multiplier)
|
||||||
end
|
end
|
||||||
|
|
||||||
function replace_ingredients_prior_to(tech, old, new, multiplier)
|
function replace_ingredients_prior_to(tech, old, new, multiplier)
|
||||||
|
log("Replacing for tech "..tech)
|
||||||
local technology = data.raw.technology[tech]
|
local technology = data.raw.technology[tech]
|
||||||
if technology then
|
if technology then
|
||||||
if technology.effects then
|
if technology.effects then
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
{
|
{
|
||||||
"name": "bzzirconium",
|
"name": "bzzirconium",
|
||||||
"version": "2.1.1",
|
"version": "2.1.2",
|
||||||
"factorio_version": "2.0",
|
"factorio_version": "2.0",
|
||||||
"title": "Zirconium",
|
"title": "Zirconium",
|
||||||
"author": "Brevven",
|
"author": "Brevven",
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue