From 07df28273d7f20f642418b2dd2ec4159999cd356 Mon Sep 17 00:00:00 2001 From: Simon Brodtmann Date: Tue, 3 Jun 2025 19:36:38 +0200 Subject: [PATCH] Improve transition to Nauvis --- README.md | 1 - lignumis/scripts/to-nauvis.lua | 70 ++++++++++++++++++------- lignumis/scripts/wooden-rocket-silo.lua | 2 + 3 files changed, 54 insertions(+), 19 deletions(-) diff --git a/README.md b/README.md index c6cb374..4669975 100644 --- a/README.md +++ b/README.md @@ -134,7 +134,6 @@ data.raw["string-setting"]["lignumis-second-planet"].default_value = "gleba" - Fix pipe graphics on desiccation furnace and quality assembler - Trees must not die when absorbing noise - https://lua-api.factorio.com/latest/types/TreeVariation.html -- Improve transition to Nauvis a bit more - Add information in Factoriopedia - Compatibility with [On Wayward Seas](https://mods.factorio.com/mod/wayward-seas) - Compatibility with [Exotic Space Industries](https://mods.factorio.com/mod/exotic-space-industries) diff --git a/lignumis/scripts/to-nauvis.lua b/lignumis/scripts/to-nauvis.lua index 7dfbd82..3985a75 100644 --- a/lignumis/scripts/to-nauvis.lua +++ b/lignumis/scripts/to-nauvis.lua @@ -29,7 +29,7 @@ end local function teleport_player(player) local nauvis = game.planets[storage.target_planet].surface if player.surface.name == "lignumis" then - local position = nauvis.find_non_colliding_position("character", { 0, 0 }, 100, 1) or { 0, 0 } + local position = nauvis.find_non_colliding_position("character", { 2, 2 }, 100, 1) or { 0, 0 } player.teleport(position, storage.target_planet) chart_starting_area(nauvis, player) end @@ -57,35 +57,69 @@ local function init_freeplay() end -ToNauvis.events[defines.events.on_rocket_launched] = function(event) - if not event.rocket_silo or event.rocket_silo.name ~= "provisional-rocket-silo" then return end +local function transit_player(player_index) + local player = game.get_player(player_index) + local transition = storage.transitions[player_index] - local rocket_entry - local rocket_entry_index - local player - - for i, entry in pairs(storage.rocket_silos) do - if entry.real_silo == event.rocket_silo then - rocket_entry = entry - rocket_entry_index = i - player = entry.player and game.get_player(entry.player) or game.players[1] - break - end - end + transition.rocket_entry.cargo_pod.set_passenger(nil) + transition.rocket_entry.cargo_pod.destroy() init_nauvis() teleport_player(player) init_freeplay() -- Give the player the content of the rocket - if rocket_entry.rocket_content then + if transition.rocket_entry.rocket_content then local inventory = player.get_main_inventory() - for _, item in pairs(rocket_entry.rocket_content) do + for _, item in pairs(transition.rocket_entry.rocket_content) do inventory.insert(item) end inventory.sort_and_merge() end - table.remove(storage.rocket_silos, rocket_entry_index) + table.remove(storage.rocket_silos, transition.rocket_entry_index) +end + + +local function explode_silo(silo) + silo.die() +end + +ToNauvis.events[defines.events.on_rocket_launch_ordered] = function(event) + if not event.rocket_silo or event.rocket_silo.name ~= "provisional-rocket-silo" then return end + + local player + + for i, entry in pairs(storage.rocket_silos) do + if entry.real_silo == event.rocket_silo then + if not storage.transitions then + storage.transitions = {} + end + player = entry.player and game.get_player(entry.player) or game.players[1] + storage.transitions[player.index] = { + rocket_entry = entry, + rocket_entry_index = i + } + break + end + end + + local transit_tick = game.tick + (26 * 59) + local explode_tick = game.tick + (31 * 59) + + script.on_nth_tick(explode_tick, function() + explode_silo(event.rocket_silo) + script.on_nth_tick(explode_tick, nil) + end) + + script.on_nth_tick(transit_tick, function() + transit_player(player.index) + script.on_nth_tick(transit_tick, nil) + end) +end + +ToNauvis.events[defines.events.on_post_entity_died] = function(event) + if not event.ghost or event.prototype.name ~= "provisional-rocket-silo" then return end + event.ghost.destroy() end return ToNauvis diff --git a/lignumis/scripts/wooden-rocket-silo.lua b/lignumis/scripts/wooden-rocket-silo.lua index c0890cf..7d3795b 100644 --- a/lignumis/scripts/wooden-rocket-silo.lua +++ b/lignumis/scripts/wooden-rocket-silo.lua @@ -92,8 +92,10 @@ local function launch(event) if entry.fake_silo == fake_silo then entry.player = event.player_index entry.rocket_content = rocket_content + entry.cargo_pod = entry.real_silo.rocket.attached_cargo_pod fake_silo.destroy() entry.real_silo.launch_rocket() + entry.cargo_pod.set_passenger(player) break end end