From db737a2d8f531a15064bc652a6a2277956eed910 Mon Sep 17 00:00:00 2001 From: Oarcinae Date: Sat, 27 Jan 2018 10:24:38 -0500 Subject: [PATCH] Should probably pass around the player name instead of the LuaPlayer object. --- separate_spawns.lua | 14 +++++++------- separate_spawns_guis.lua | 6 +++--- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/separate_spawns.lua b/separate_spawns.lua index 33b7635..cb63e26 100644 --- a/separate_spawns.lua +++ b/separate_spawns.lua @@ -245,7 +245,7 @@ function ChangePlayerSpawn(player, pos) global.playerCooldowns[player.name] = {setRespawn=game.tick} end -function QueuePlayerForDelayedSpawn(player, spawn, moatEnabled) +function QueuePlayerForDelayedSpawn(playerName, spawn, moatEnabled) -- If we get a valid spawn point, setup the area if ((spawn.x ~= 0) and (spawn.y ~= 0)) then @@ -254,7 +254,7 @@ function QueuePlayerForDelayedSpawn(player, spawn, moatEnabled) player.print("Generating your spawn now, please wait 10 seconds...") player.surface.request_to_generate_chunks(spawn, 4) delayedTick = game.tick + 10*TICKS_PER_SECOND - table.insert(global.delayedSpawns, {player=player, spawn=spawn, moatEnabled=moatEnabled, delayedTick=delayedTick}) + table.insert(global.delayedSpawns, {playerName=playerName, spawn=spawn, moatEnabled=moatEnabled, delayedTick=delayedTick}) else DebugPrint("THIS SHOULD NOT EVER HAPPEN! Spawn failed!") @@ -273,8 +273,8 @@ function DelayedSpawnOnTick() delayedSpawn = global.delayedSpawns[i] if (delayedSpawn.delayedTick < game.tick) then - if (delayedSpawn.player ~= nil) then - SendPlayerToNewSpawnAndCreateIt(delayedSpawn.player, delayedSpawn.spawn, delayedSpawn.moatEnabled) + if (game.players[delayedSpawn.playerName] ~= nil) then + SendPlayerToNewSpawnAndCreateIt(delayedSpawn.playerName, delayedSpawn.spawn, delayedSpawn.moatEnabled) end table.remove(global.delayedSpawns, i) end @@ -283,7 +283,7 @@ function DelayedSpawnOnTick() end end -function SendPlayerToNewSpawnAndCreateIt(player, spawn, moatEnabled) +function SendPlayerToNewSpawnAndCreateIt(playerName, spawn, moatEnabled) -- Make sure the area is super safe. ClearNearbyEnemies(spawn, SAFE_AREA_TILE_DIST, game.surfaces[GAME_SURFACE_NAME]) @@ -298,8 +298,8 @@ function SendPlayerToNewSpawnAndCreateIt(player, spawn, moatEnabled) GenerateStartingResources(surface, spawn) -- Send the player to that position - player.teleport(spawn, GAME_SURFACE_NAME) - GivePlayerStarterItems(player) + game.players[playerName].teleport(spawn, GAME_SURFACE_NAME) + GivePlayerStarterItems(game.players[playerName]) end function SendPlayerToSpawn(player) diff --git a/separate_spawns_guis.lua b/separate_spawns_guis.lua index 9faca09..90dfc46 100755 --- a/separate_spawns_guis.lua +++ b/separate_spawns_guis.lua @@ -399,7 +399,7 @@ function SpawnOptsGuiClick(event) ChangePlayerSpawn(player, newSpawn) -- Send the player there - QueuePlayerForDelayedSpawn(player, newSpawn, moatChoice) + QueuePlayerForDelayedSpawn(player.name, newSpawn, moatChoice) if (elemName == "isolated_spawn_near") then SendBroadcastMsg(player.name .. " is joining the game from a distance!") elseif (elemName == "isolated_spawn_far") then @@ -1282,8 +1282,8 @@ function BuddySpawnRequestMenuClick(event) ChangePlayerSpawn(game.players[requesterName], buddySpawn) -- Send the player there - QueuePlayerForDelayedSpawn(player, newSpawn, requesterOptions.moatChoice) - QueuePlayerForDelayedSpawn(game.players[requesterName], buddySpawn, requesterOptions.moatChoice) + QueuePlayerForDelayedSpawn(player.name, newSpawn, requesterOptions.moatChoice) + QueuePlayerForDelayedSpawn(requesterName, buddySpawn, requesterOptions.moatChoice) SendBroadcastMsg(requesterName .. " and " .. player.name .. " are joining the game together!") -- Create the button at the top left for setting respawn point and sharing base.