Prevent possible errors on player initialization

This commit is contained in:
Simon Brodtmann 2025-03-04 09:56:59 +01:00
parent 8e1c774e2a
commit f91f364c8d

View file

@ -22,10 +22,10 @@ end
-- Teleport to Lignumis and give some starting items
local function init_player(event)
local player = game.get_player(event.player_index)
if not player.character then return end
local surface = storage.surface or game.planets["lignumis"].surface
if not player.character or not surface then return end
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()