From dd45cac7db2f0fa393244e59d328d4fbf28567ca Mon Sep 17 00:00:00 2001 From: Simon Brodtmann Date: Sat, 11 Jan 2025 15:28:27 +0100 Subject: [PATCH] Fix bug for when freeplay interface is not present https://mods.factorio.com/mod/lignumis/discussion/67801be5358edef99aaf00eb --- lignumis/changelog.txt | 2 ++ lignumis/control.lua | 32 +++++++++++++++++++------------- lignumis/script/to-nauvis.lua | 13 ++++++++----- 3 files changed, 29 insertions(+), 18 deletions(-) diff --git a/lignumis/changelog.txt b/lignumis/changelog.txt index bfaf999..8eb8c4a 100644 --- a/lignumis/changelog.txt +++ b/lignumis/changelog.txt @@ -7,6 +7,8 @@ Date: 09.01.2025 - Balance peat resource patches - Increase fuel value of wood pulp - Balance start on Nauvis + - Fix bug for when freeplay interface is not present + - Reactors and cars burn wood fuel --------------------------------------------------------------------------------------------------- Version: 0.0.5 Date: 07.01.2025 diff --git a/lignumis/control.lua b/lignumis/control.lua index 115ffee..0fa9bbb 100644 --- a/lignumis/control.lua +++ b/lignumis/control.lua @@ -53,24 +53,30 @@ script.on_event(e.on_player_created, function(event) if not storage.init then storage.init = true - storage.crashed_ship_items = remote.call("freeplay", "get_ship_items") - storage.crashed_debris_items = remote.call("freeplay", "get_debris_items") - storage.crashed_ship_parts = remote.call("freeplay", "get_ship_parts") - storage.starting_message = remote.call("freeplay", "get_custom_intro_message") - - local ship_items = { ["wood-darts-magazine"] = 8 } - local debris_items = { ["lumber"] = 8 } surface.daytime = 0.7 - crash_site.create_crash_site(surface, { -5, -6 }, ship_items, debris_items, table.deepcopy(storage.crashed_ship_parts)) - util.remove_safe(player, storage.crashed_ship_items) - util.remove_safe(player, storage.crashed_debris_items) - player.get_main_inventory().sort_and_merge() if player.character then player.character.destructible = false end - storage.crash_site_cutscene_active = true - crash_site.create_cutscene(player, { -5, -4 }) + + if remote.interfaces.freeplay then + storage.crashed_ship_items = remote.call("freeplay", "get_ship_items") + storage.crashed_debris_items = remote.call("freeplay", "get_debris_items") + storage.crashed_ship_parts = remote.call("freeplay", "get_ship_parts") + storage.starting_message = remote.call("freeplay", "get_custom_intro_message") + + local ship_items = { ["wood-darts-magazine"] = 8 } + local debris_items = { ["lumber"] = 8 } + + crash_site.create_crash_site(surface, { -5, -6 }, ship_items, debris_items, table.deepcopy(storage.crashed_ship_parts)) + util.remove_safe(player, storage.crashed_ship_items) + util.remove_safe(player, storage.crashed_debris_items) + + player.get_main_inventory().sort_and_merge() + + storage.crash_site_cutscene_active = true + crash_site.create_cutscene(player, { -5, -4 }) + end chart_starting_area() end diff --git a/lignumis/script/to-nauvis.lua b/lignumis/script/to-nauvis.lua index 29463e1..cbf8739 100644 --- a/lignumis/script/to-nauvis.lua +++ b/lignumis/script/to-nauvis.lua @@ -23,12 +23,15 @@ local function travel_to_nauvis() end end - local ship_items = { ["burner-mining-drill"] = 5, ["stone-furnace"] = 5, ["burner-assembling-machine"] = 2, ["burner-agricultural-tower"] = 4, ["wood-lab"] = 4 } - local debris_items = { ["wood-darts-magazine"] = 20, ["wood"] = 20, ["lumber"] = 20 } - local crashed_ship_parts = remote.call("freeplay", "get_ship_parts") - nauvis.daytime = 0.7 - crash_site.create_crash_site(nauvis, { -5, -6 }, ship_items, debris_items, table.deepcopy(crashed_ship_parts)) + + if remote.interfaces.freeplay then + local ship_items = { ["burner-mining-drill"] = 5, ["stone-furnace"] = 5, ["burner-assembling-machine"] = 2, ["burner-agricultural-tower"] = 4, ["wood-lab"] = 4 } + local debris_items = { ["wood-darts-magazine"] = 20, ["wood"] = 20, ["lumber"] = 20 } + local crashed_ship_parts = remote.call("freeplay", "get_ship_parts") + + crash_site.create_crash_site(nauvis, { -5, -6 }, ship_items, debris_items, table.deepcopy(crashed_ship_parts)) + end end script.on_event(e.on_rocket_launched, function(event)