forked from cacklingfiend/lignumis
Fix errors with initialization
This commit is contained in:
parent
c660647341
commit
87b36d88d1
1 changed files with 45 additions and 35 deletions
|
@ -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)
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue