diff --git a/changelog.txt b/changelog.txt index b8fea50..27d7ad1 100644 --- a/changelog.txt +++ b/changelog.txt @@ -1,4 +1,17 @@ --------------------------------------------------------------------------------------------------- +Version: 2.0.6 +Date: 2025-01-29 + Changes: + - Changes to Any Planet Start progression + - Maraxsis: Can make silica from sand, silica is used for glass on Maraxsis. + Fixes: + - Fix razorgrass regenerate +--------------------------------------------------------------------------------------------------- +Version: 2.0.5 +Date: 2025-01-25 + Fixes: + - Improve compatibility with mods that modify armor recipes in certain ways +--------------------------------------------------------------------------------------------------- Version: 2.0.4 Date: 2025-01-16 Changes: diff --git a/compatibility/any-planet-start.lua b/compatibility/any-planet-start.lua index 9562544..dbf90c9 100644 --- a/compatibility/any-planet-start.lua +++ b/compatibility/any-planet-start.lua @@ -4,7 +4,8 @@ if mods["any-planet-start"] and util.me.get_setting("aps-planet") == "vulcanus" util.set_prerequisite("silica-processing", {}) util.add_unlock("automation", "basic-crusher") util.set_prerequisite("silicon-processing", {"silica-processing"}) - util.set_tech_trigger("silica-processing", {type = "mine-entity", entity="huge-volcanic-rock"}) + util.set_tech_trigger("silica-processing", {type = "mine-entity", entity="vulcanus-chimney-truncated"}) + util.replace_ingredient("solar-cell", "silicon-wafer", "silicon") util.set_tech_trigger("silicon-processing", {type = "craft-item", item="silica", count=50}) if util.me.more_intermediates() then util.add_new_crafting_category("handcrafting", true) @@ -27,7 +28,7 @@ if mods["any-planet-start"] and util.me.get_setting("aps-planet") == "vulcanus" util.add_unlock("silicon-processing", "silicon-wafer-by-hand") end elseif mods["any-planet-start"] and util.me.get_setting("aps-planet") == "fulgora" then - util.set_prerequisite("silica-processing", {"automation-science-pack"}) + util.set_prerequisite("silica-processing", {"automation-2"}) util.set_prerequisite("silicon-processing", {"silica-processing"}) util.remove_prerequisite("advanced-circuit", "silicon-processing") elseif mods["any-planet-start"] and util.me.get_setting("aps-planet") == "gleba" then diff --git a/control-util.lua b/control-util.lua index ef04e99..c21f3aa 100644 --- a/control-util.lua +++ b/control-util.lua @@ -58,8 +58,17 @@ function list(event) 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() - script.on_event(defines.events.on_console_command, list) + util.add_command_handler() if not commands.commands[list_command] then 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. ]] 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 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 if #params == 1 and params[1] == "all" then for _, resource in pairs(me.resources) do - if prototypes.entity[resource] then - game.print("Regenerating "..resource) - game.regenerate_entity(resource) + if prototypes.entity[resource[1]] then + game.print("Regenerating "..resource[1]) + game.regenerate_entity(resource[1]) end end 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.") return end - if resource == params[2] then + if resource[1] == params[2] and resource[2] == planet then if #params == 5 then local settings = {frequency=params[3], size=params[4], richness=params[5]} local map_gen_settings = game.surfaces[planet].map_gen_settings - map_gen_settings.autoplace_controls[resource] = settings - map_gen_settings.autoplace_settings.entity.settings[resource] = settings + map_gen_settings.autoplace_controls[resource[1]] = settings + map_gen_settings.autoplace_settings.entity.settings[resource[1]] = 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 - game.print("Regenerating "..resource) - game.surfaces[planet].regenerate_entity(resource) + game.print("Regenerating "..resource[1]) + game.surfaces[planet].regenerate_entity(resource[1]) end end end @@ -182,6 +191,7 @@ end function util.ore_fix() ore_fix("nauvis") + ore_fix("vulcanus") if game.surfaces.tenebris then ore_fix("tenebris") end @@ -189,14 +199,18 @@ end function ore_fix(surface_name) for _, resource in pairs(me.resources) do - local map_gen_settings = game.surfaces[surface_name].map_gen_settings - if map_gen_settings.autoplace_controls[resource] == nil then - map_gen_settings.autoplace_controls[resource] = {} + if resource[2] == surface_name then + if game.surfaces[resource[2]] then + local map_gen_settings = game.surfaces[surface_name].map_gen_settings + if map_gen_settings.autoplace_controls[resource[1]] == nil then + map_gen_settings.autoplace_controls[resource[1]] = {} + end + if map_gen_settings.autoplace_settings.entity.settings[resource[1]] == nil then + map_gen_settings.autoplace_settings.entity.settings[resource[1]] = {} + end + game.surfaces[surface_name].map_gen_settings = map_gen_settings + end end - if map_gen_settings.autoplace_settings.entity.settings[resource] == nil then - map_gen_settings.autoplace_settings.entity.settings[resource] = {} - end - game.surfaces[surface_name].map_gen_settings = map_gen_settings end end diff --git a/data-util.lua b/data-util.lua index 5f39a0d..9b471b3 100644 --- a/data-util.lua +++ b/data-util.lua @@ -785,7 +785,7 @@ 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 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) prepare_redo_recycling(recipe_name) add_or_add_to_ingredient(data.raw.recipe[recipe_name], ingredient, quantity) @@ -800,15 +800,25 @@ function add_or_add_to_ingredient(recipe, ingredient, quantity) return end end - table.insert(recipe.ingredients, {ingredient, quantity}) + table.insert(recipe.ingredients, util.item(ingredient, quantity)) end 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 + -- 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 local is_fluid = not not data.raw.fluid[ingredient] - if data.raw.recipe[recipe_name] and (data.raw.item[ingredient] or is_fluid) then + if data.raw.recipe[recipe_name] and (util.get_item(ingredient) or is_fluid) then me.add_modified(recipe_name) prepare_redo_recycling(recipe_name) add_ingredient(data.raw.recipe[recipe_name], ingredient, quantity, is_fluid) @@ -912,14 +922,20 @@ function util.get_ingredient_amount(recipe_name, ingredient_name) return 0 end --- Get the amount of the result +-- Get the amount of the result (currently ignores probability) 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 for i, result in pairs(recipe.results) do - if result.name == product then return result.amount end + if result.name == product then + if result.amount then + return result.amount + elseif result.amount_min then + return (result.amount_min + result.amount_max) / 2 + end + end end end return 0 @@ -944,7 +960,7 @@ end -- 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 data.raw.recipe[recipe_name] and (data.raw.item[new] or data.raw.fluid[new]) then + 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) replace_ingredient(data.raw.recipe[recipe_name], old, new, amount, multiply) @@ -1019,7 +1035,7 @@ function replace_some_product(recipe, old, old_amount, new, new_amount) end end end - add_product(recipe, {new, new_amount}) + add_product(recipe, util.item(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) @@ -1475,15 +1491,11 @@ function util.add_to_ingredient(recipe, ingredient, amount, options) end 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 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 @@ -1513,7 +1525,7 @@ 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] and data.raw[t][name] and data.raw[t][name].minable and data.raw.item[result.name] then if data.raw[t][name].minable.result and not data.raw[t][name].minable.results then data.raw[t][name].minable.results = { util.item(data.raw[t][name].minable.result ,data.raw[t][name].minable.count)} @@ -1521,6 +1533,9 @@ function util.add_minable_result(t, name, result) data.raw[t][name].minable.result_count = nil 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 + end table.insert(data.raw[t][name].minable.results, result) else data.raw[t][name].minable.results = {result} @@ -1528,6 +1543,16 @@ function util.add_minable_result(t, name, result) 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) table.insert(node, value) -- store as parameter @@ -1612,6 +1637,7 @@ end function remove_prior_unlocks(tech, recipe) local technology = data.raw.technology[tech] if technology then + log("Removing prior unlocks for ".. tech) util.remove_recipe_effect(tech, recipe) if technology.prerequisites then for i, prerequisite in pairs(technology.prerequisites) do @@ -1647,6 +1673,7 @@ function util.replace_ingredients_prior_to(tech, old, new, multiplier) end function replace_ingredients_prior_to(tech, old, new, multiplier) + log("Replacing for tech "..tech) local technology = data.raw.technology[tech] if technology then if technology.effects then @@ -1760,6 +1787,21 @@ function util.redo_recycling() recycling.generate_recycling_recipe(recipe) end end + -- Find all recycling recipes that result in armor and make sure not to output more than 1 + for _, recipe in pairs(data.raw.recipe) do + if recipe.name:find("recycling") then + for _, product in pairs(recipe.results) do + if data.raw.armor[product.name] then + if product.amount then + if product.amount > .99 then + product.amount = 1 + product.extra_count_fraction = nil + end + end + end + end + end + end end end @@ -1768,6 +1810,15 @@ function prepare_redo_recycling(recipe_name) data.raw.recipe[recipe_name].redo_recycling = true end +-- Change furnace output count +function util.set_minimum_furnace_outputs(category, count) + for i, entity in pairs(data.raw.furnace) do + if entity.result_inventory_size ~= nil and entity.result_inventory_size < count and util.contains(entity.crafting_categories, category) then + entity.result_inventory_size = count + end + end +end + -- According to https://mods.factorio.com/mod/Asteroid_Mining, the -- following function is under this MIT license (similar license, different author): diff --git a/info.json b/info.json index da3b208..4d29aa9 100644 --- a/info.json +++ b/info.json @@ -1,6 +1,6 @@ { "name": "bzsilicon", - "version": "2.0.4", + "version": "2.0.6", "factorio_version": "2.0", "title": "Silica & Silicon", "author": "Brevven", diff --git a/locale/en/silicon.cfg b/locale/en/silicon.cfg index c986604..f06ab23 100644 --- a/locale/en/silicon.cfg +++ b/locale/en/silicon.cfg @@ -55,7 +55,7 @@ razorgrass-ash-washing=Silica from ash stone-from-lava=Stone from lava [recipe-description] -razorgrass-dried=A furnace is required to dry razorgrass release its seeds. +razorgrass-dried=A furnace is required to dry razorgrass and release its seeds. # Settings diff --git a/me.lua b/me.lua index e6033b3..cf697c7 100644 --- a/me.lua +++ b/me.lua @@ -1,6 +1,6 @@ local me = {} me.name = "bzsilicon" -me.resources = {"razorgrass"} +me.resources = {{"razorgrass-plant", "gleba"}} me.silicon_processing = (mods and mods["Krastorio2"] and "kr-silicon-processing") or "silicon-processing" me.recipes = {"silica", "silicon", "optical-fiber", "silicon-wafer", "solar-cell", "gyro", "silicon-smelting-vulcanite"} diff --git a/prototypes/basic-crusher.lua b/prototypes/basic-crusher.lua index 81874a4..322c1ba 100644 --- a/prototypes/basic-crusher.lua +++ b/prototypes/basic-crusher.lua @@ -65,7 +65,7 @@ data:extend({ { type = "item", name = "basic-crusher", - icon = "__space-age__/graphics/icons/crusher.png", + icons = {{icon = "__space-age__/graphics/icons/crusher.png", icon_size=64, scale=0.8, tint={.7,.7,.7}}}, subgroup = "production-machine", order = "s[crusher]", inventory_move_sound = item_sounds.drill_inventory_move, @@ -78,6 +78,7 @@ data:extend({ { type = "furnace", name = "basic-crusher", + icons = {{icon = "__space-age__/graphics/icons/crusher.png", icon_size=64, scale=0.8, tint={.7,.7,.7}}}, source_inventory_size = 1, result_inventory_size = 1, icon = "__space-age__/graphics/icons/crusher.png", diff --git a/prototypes/silica-recipe.lua b/prototypes/silica-recipe.lua index f50a932..6c13d49 100644 --- a/prototypes/silica-recipe.lua +++ b/prototypes/silica-recipe.lua @@ -125,3 +125,18 @@ data:extend( }, } ) +if mods.maraxsis then +data:extend({ + { + type = "recipe", + name = "silica-from-sand-maraxsis", + localised_name = {"item-name.silica"}, + category = "basic-crushing", + enabled = false, + energy_required = 1.6, + allow_productivity = true, + ingredients = {util.item("sand", 1)}, + results = {util.item("silica", 5)}, + } +}) +end diff --git a/recipe-updates.lua b/recipe-updates.lua index 26e3eb5..8bff58b 100644 --- a/recipe-updates.lua +++ b/recipe-updates.lua @@ -281,3 +281,7 @@ if mods["space-age"] then log(serpent.block(data.raw.recipe["sand"])) end end + +-- Maraxsis +util.replace_ingredient("maraxsis-glass-panes", "sand", "silica", 10) +util.add_unlock("maraxsis-glassworking", "silica-from-sand-maraxsis")