Make the second planet after Lignumis configurable by other mods

This commit is contained in:
Simon Brodtmann 2025-03-17 18:01:15 +01:00
parent 8982b1bf82
commit ac60c67999
5 changed files with 29 additions and 6 deletions

View file

@ -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

View file

@ -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

View file

@ -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,

View file

@ -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
}
})