mirror of
https://github.com/ComfyFactory/ComfyFactorio.git
synced 2025-03-25 21:29:06 +02:00
spectator fixes
This commit is contained in:
parent
6753ae3333
commit
cfa055e4e4
@ -27,12 +27,14 @@ local function on_gui_click(event)
|
||||
if not event.element then return end
|
||||
if not event.element.valid then return end
|
||||
local player = game.players[event.element.player_index]
|
||||
if player.force.index == 1 then return end
|
||||
if event.element.name == "cancel_spectate" then player.gui.center["spectate_confirmation_frame"].destroy() return end
|
||||
if event.element.name == "confirm_spectate" then
|
||||
player.gui.center["spectate_confirmation_frame"].destroy()
|
||||
if player.character then player.character.die() end
|
||||
player.force = game.forces.player
|
||||
player.character = nil
|
||||
player.spectator = true
|
||||
player.set_controller({type=defines.controllers.spectator})
|
||||
game.print(player.name .. " has turned into a spectator ghost.")
|
||||
return
|
||||
|
@ -112,6 +112,7 @@ function Public.reset_map()
|
||||
|
||||
for _, player in pairs(game.connected_players) do
|
||||
if player.gui.left.biter_hatchery_game_won then player.gui.left.biter_hatchery_game_won.destroy() end
|
||||
player.spectator = false
|
||||
player.teleport(surface.find_non_colliding_position("character", player.force.get_spawn_position(surface), 32, 0.5), surface)
|
||||
end
|
||||
end
|
||||
@ -213,6 +214,8 @@ local border_teleport = {
|
||||
|
||||
local function on_player_changed_position(event)
|
||||
local player = game.players[event.player_index]
|
||||
if not player.character then return end
|
||||
if not player.character.valid then return end
|
||||
if player.position.x >= -4 and player.position.x <= 4 then
|
||||
if player.character.driving then player.character.driving = false end
|
||||
player.teleport({player.position.x + border_teleport[player.force.name], player.position.y}, game.surfaces[global.active_surface_index])
|
||||
|
Loading…
x
Reference in New Issue
Block a user