1
0
mirror of https://github.com/ComfyFactory/ComfyFactorio.git synced 2025-01-26 03:52:22 +02:00

Mtn v3 - minor fixes

This commit is contained in:
Gerkiz 2022-11-08 00:09:13 +01:00
parent c8db36bc4f
commit bc45c4a165
7 changed files with 69 additions and 14 deletions

View File

@ -1625,6 +1625,11 @@ function Public.set_player_to_spectator(player)
player.print('[color=blue][Spectate][/color] You are in combat. Try again soon.', Color.warning)
return false
end
if player.driving then
return player.print('[color=blue][Spectate][/color] Please exit the vehicle before continuing', Color.warning)
end
local spectate = Public.get('spectate')
if not spectate[player.index] then
@ -1641,14 +1646,14 @@ function Public.set_player_to_spectator(player)
player.character = nil
player.spectator = true
player.tag = '[Spectator]'
player.tag = '[img=utility/ghost_time_to_live_modifier_icon]'
player.set_controller({type = defines.controllers.spectator})
game.print('[color=blue][Spectate][/color] ' .. player.name .. ' is now spectating.')
Server.to_discord_bold(table.concat {'*** ', '[Spectate] ' .. player.name .. ' is now spectating.', ' ***'})
if spectate[player.index] and not spectate[player.index].delay then
spectate[player.index].verify = true
spectate[player.index].delay = game.tick + 18000
spectate[player.index].delay = game.tick + 3600
end
return true
end

View File

@ -158,7 +158,7 @@ end
local function hide_all_gui(player)
for _, child in pairs(player.gui.top.children) do
if child.name ~= spectate_button_name then
if child.name ~= spectate_button_name and child.name ~= 'minimap_button' then
child.visible = false
end
end
@ -166,7 +166,7 @@ end
local function show_all_gui(player)
for _, child in pairs(player.gui.top.children) do
if child.name ~= spectate_button_name then
if child.name ~= spectate_button_name and child.name ~= 'minimap_button' then
child.visible = true
end
end
@ -178,13 +178,13 @@ local function on_player_joined_game(event)
return
end
if not player.gui.top[main_button_name] then
create_button(player)
end
if not player.gui.top[spectate_button_name] then
spectate_button(player)
end
if not player.gui.top[main_button_name] then
create_button(player)
end
end
local function on_gui_click(event)
@ -289,6 +289,7 @@ local function on_player_changed_surface(event)
local info = player.gui.top[main_button_name]
local wd = player.gui.top['wave_defense']
local spectate = player.gui.top[spectate_button_name]
local minimap_button = player.gui.top['minimap_button']
local rpg_b = player.gui.top[rpg_button]
local rpg_f = player.gui.screen[rpg_frame]
local rpg_s = player.gui.screen[rpg_settings]
@ -325,6 +326,9 @@ local function on_player_changed_surface(event)
if rpg_b and not rpg_b.visible then
rpg_b.visible = true
end
if minimap_button and not minimap_button.visible then
minimap_button.visible = false
end
if spell_cast_buttons and not spell_cast_buttons.visible then
spell_cast_buttons.visible = true
end
@ -352,6 +356,9 @@ local function on_player_changed_surface(event)
if spectate then
spectate.visible = false
end
if minimap_button and not minimap_button.visible then
minimap_button.visible = false
end
if rpg_b then
rpg_b.visible = false
end

View File

@ -133,7 +133,16 @@ local function on_gui_closed(event)
return
end
Minimap.kill_minimap(game.players[event.player_index])
local player = game.get_player(event.player_index)
if not player or not player.valid then
return
end
if player.controller_type == defines.controllers.spectator then
return
end
Minimap.kill_minimap(player)
end
local function on_gui_opened(event)
@ -151,6 +160,15 @@ local function on_gui_opened(event)
return
end
local player = game.get_player(event.player_index)
if not player or not player.valid then
return
end
if player.controller_type == defines.controllers.spectator then
return
end
local surface_index = car.surface
local surface = game.surfaces[surface_index]
if not surface or not surface.valid then
@ -158,7 +176,7 @@ local function on_gui_opened(event)
end
Minimap.minimap(
game.players[event.player_index],
player,
surface,
{
car.area.left_top.x + (car.area.right_bottom.x - car.area.left_top.x) * 0.5,

View File

@ -46,7 +46,12 @@ local function on_gui_closed(event)
if not icw.wagons[entity.unit_number] then
return
end
Functions.kill_minimap(game.players[event.player_index])
local player = game.get_player(event.player_index)
if not player or not player.valid then
return
end
Functions.kill_minimap(player)
end
local function on_gui_opened(event)
@ -66,9 +71,14 @@ local function on_gui_opened(event)
return
end
local player = game.get_player(event.player_index)
if not player or not player.valid then
return
end
Functions.draw_minimap(
icw,
game.players[event.player_index],
player,
wagon.surface,
{
wagon.area.left_top.x + (wagon.area.right_bottom.x - wagon.area.left_top.x) * 0.5,
@ -78,7 +88,8 @@ local function on_gui_opened(event)
end
local function on_player_died(event)
Functions.kill_minimap(game.players[event.player_index])
local player = game.get_player(event.player_index)
Functions.kill_minimap(player)
end
local function on_train_created()

View File

@ -782,7 +782,13 @@ local function gui_opened(event)
return
end
local player = game.players[event.player_index]
local player = game.get_player(event.player_index)
if not player or not player.valid then
return
end
if player.controller_type == defines.controllers.spectator then
return
end
if not validate_player(player) then
return

View File

@ -453,6 +453,10 @@ local function container_opened(event)
return
end
if player.controller_type == defines.controllers.spectator then
return
end
Public.add_mystical_chest(player)
end

View File

@ -596,6 +596,10 @@ local function on_gui_opened(event)
return
end
if player.controller_type == defines.controllers.spectator then
return
end
local corpse_content = #event.entity.get_inventory(defines.inventory.character_corpse)
if corpse_content <= 0 then
return