Fix errors with initialization

This commit is contained in:
Simon Brodtmann 2025-01-20 23:14:42 +01:00
parent c660647341
commit 87b36d88d1

View file

@ -22,7 +22,10 @@ end
script.on_init(function()
if game.tick > 0 then
storage.init = true
storage.init = {}
for _, player in pairs(game.players) do
storage.init[player.index] = true
end
game.print { "", { "lignumis.start-new-game" } }
return
end
@ -59,13 +62,24 @@ script.on_event(e.on_player_created, function(event)
nauvis.clear()
end
if storage.init and type(storage.init) == "boolean" then
storage.init = {
[event.player_index] = true
}
else
storage.init = {}
end
local player = game.get_player(event.player_index) --[[@as LuaPlayer]]
local surface = storage.surface
local surface = storage.surface or game.planets["lignumis"].surface
if not storage.init[event.player_index] then
storage.init[event.player_index] = true
chart_starting_area()
if player then
player.teleport(surface.find_non_colliding_position("character", { 0, 0 }, 0, 1), "lignumis")
if player.character then
player.teleport(surface.find_non_colliding_position("character", { 0, 0 }, 0, 1), "lignumis")
player.character.destructible = false
local main_inventory = player.character.get_main_inventory()
main_inventory.insert({ name = "burner-mining-drill", count = 1 })
@ -92,10 +106,6 @@ script.on_event(e.on_player_created, function(event)
crash_site.create_cutscene(player, { -5, -4 })
end
end
if not storage.init then
storage.init = true
chart_starting_area()
end
end)