From ac60c67999882f2d441e7614474d9d100f9c37dd Mon Sep 17 00:00:00 2001 From: Simon Brodtmann Date: Mon, 17 Mar 2025 18:01:15 +0100 Subject: [PATCH] Make the second planet after Lignumis configurable by other mods --- README.md | 12 ++++++++++++ lignumis/scripts/init-new.lua | 2 +- lignumis/scripts/init.lua | 4 +++- lignumis/scripts/to-nauvis.lua | 9 +++++---- lignumis/settings.lua | 8 ++++++++ 5 files changed, 29 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index 7292cea..d8c6fd1 100644 --- a/README.md +++ b/README.md @@ -105,6 +105,18 @@ Don't touch inputs for labs in this list. Lignumis adds wood and steam science packs to all labs' inputs in `data-updates.lua` so modded labs will support them. If your modded lab is special and it should not support these science packs, use this list or set the inputs in `data-final-fixes.lua`. +#### Chaning the second planet (a.k.a. transition to Nauvis) + +If you want to create a mod that moves Lignumis to another planet, there is a hidden setting for the scripted transition to teleport the player not to Nauvis but to any planet you like. +This doesn't change any technologies or the location of Lignumis on the map. Make sure you adjust the prototypes as well on your end. + +In `settings-updates.lua` add the following to switch to Gleba as the second planet: + +```lua +data.raw["string-setting"]["lignumis-second-planet"].allowed_values = { "gleba" } +data.raw["string-setting"]["lignumis-second-planet"].default_value = "gleba" +``` + ## Todo - Fix pipe graphics on desiccation furnace and quality assembler diff --git a/lignumis/scripts/init-new.lua b/lignumis/scripts/init-new.lua index efe1a07..f81bf46 100644 --- a/lignumis/scripts/init-new.lua +++ b/lignumis/scripts/init-new.lua @@ -33,7 +33,7 @@ end local function init_space_locations() local force = game.forces.player force.technologies["planet-discovery-lignumis"].researched = true - if not force.technologies["planet-discovery-nauvis"].researched then + if game.planets["nauvis"] and force.technologies["planet-discovery-nauvis"] and not force.technologies["planet-discovery-nauvis"].researched then force.lock_space_location("nauvis") end end diff --git a/lignumis/scripts/init.lua b/lignumis/scripts/init.lua index 69aab8e..1ff844b 100644 --- a/lignumis/scripts/init.lua +++ b/lignumis/scripts/init.lua @@ -7,6 +7,8 @@ local Init = { events = {} } +local target_planet = settings.global["lignumis-second-planet"].value or "nauvis" + -- Migrate storage init as it was just a boolean before not supporting multiple players local function migrate_0_9_6(event) @@ -94,7 +96,7 @@ Init.events[defines.events.on_player_changed_surface] = function(event) if player.controller_type ~= defines.controllers.character then return end - if player and player.surface.name == "nauvis" then + if player and player.surface.name == target_planet then storage.nauvis_visited = true end diff --git a/lignumis/scripts/to-nauvis.lua b/lignumis/scripts/to-nauvis.lua index c2b3bc3..c8dd0e6 100644 --- a/lignumis/scripts/to-nauvis.lua +++ b/lignumis/scripts/to-nauvis.lua @@ -6,6 +6,7 @@ local ToNauvis = { events = {} } +local target_planet = settings.global["lignumis-second-planet"].value or "nauvis" -- Chart the starting area for the player local function chart_starting_area(surface, player) @@ -19,7 +20,7 @@ end -- Initialize Nauvis local function init_nauvis() if storage.nauvis_visited then return end - local nauvis = game.planets["nauvis"].create_surface() + local nauvis = game.planets[target_planet].create_surface() nauvis.request_to_generate_chunks({ 0, 0 }, 3) nauvis.force_generate_chunk_requests() nauvis.daytime = 0.7 @@ -28,10 +29,10 @@ end -- Teleport player to Nauvis and show welcome message local function teleport_player(player) - local nauvis = game.planets["nauvis"].surface + local nauvis = game.planets[target_planet].surface if player.surface.name == "lignumis" then local position = nauvis.find_non_colliding_position("character", { 0, 0 }, 100, 1) or { 0, 0 } - player.teleport(position, "nauvis") + player.teleport(position, target_planet) chart_starting_area(nauvis, player) player.print("Oh no, not again. But... Welcome to Nauvis!") end @@ -44,7 +45,7 @@ local function init_freeplay() if not remote.interfaces.freeplay then return end storage.crashed_ship_nauvis = true - local nauvis = game.planets["nauvis"].surface + local nauvis = game.planets[target_planet].surface local ship_items = { ["burner-mining-drill"] = 2, ["stone-furnace"] = 2, diff --git a/lignumis/settings.lua b/lignumis/settings.lua index 3da6341..d23e183 100644 --- a/lignumis/settings.lua +++ b/lignumis/settings.lua @@ -54,6 +54,14 @@ data:extend({ setting_type = "startup", default_value = false, order = "h" + }, + { + type = "string-setting", + name = "lignumis-second-planet", + setting_type = "runtime-global", + allowed_values = { "nauvis" }, + default_value = "nauvis", + hidden = true } })