1
0
mirror of https://github.com/ComfyFactory/ComfyFactorio.git synced 2024-12-30 23:17:53 +02:00

remove spectator mode

This commit is contained in:
danielmartin0 2024-09-27 21:30:57 +01:00 committed by Gerkiz
parent 518e8a1341
commit 718c97475b
13 changed files with 48 additions and 571 deletions

View File

@ -358,10 +358,6 @@ choose_chat_color=__1__ chose the color __2__
randomize_chat_color=__1__'s color randomized to __2__
crew_to_spectator=__1__ left the crew to become a spectator.
lobby_to_spectator=__1__ joined as a spectator.
lobby_to_spectator_2=__1__ left the lobby to spectate __2__.
spectator_to_lobby=__1__ stopped spectating and returned to the lobby.
lobby_to_crew=__1__ joined the crew.
lobby_to_crew_2=__1__ left the lobby to join __2__.
crew_leave=__1__ left the crew.
@ -441,16 +437,12 @@ fuel_tooltip=Stored fuel: __1__.\n\nTo store more, send coal to the captain's ca
gui_crew_window_buttons_quit_crew=Quit Crew
gui_crew_window_buttons_quit_crew_tooltip=Return to the lobby.
gui_crew_window_buttons_quit_spectators=Return to Lobby
gui_crew_window_buttons_join_crew=Join Crew
gui_crew_window_buttons_join_spectators=Spectate
gui_crew_window_buttons_join_spectators_tooltip=You won't be able to rejoin the crew for a short while after you do this.
gui_crew_window_crewmembers=Crew Members
# gui_crew_window_crewmembers_give_up_class=Give Up Class
# gui_crew_window_crewmembers_give_up_class_tooltip=Give Up Class
gui_crew_window_crewmembers_resign_as_officer=Resign as Officer
gui_crew_window_crewmembers_resign_as_officer_tooltip=Give up the officer role.
gui_crew_window_spectators=Spectators
gui_crew_window_vote_for_difficulty=Vote for Difficulty
# gui_crew_window_spare_classes=Spare Classes
# gui_crew_window_assign_class_button=Give class: __1__
@ -466,7 +458,7 @@ gui_crew_window_captains_actions_renounce_title=Renounce Captainhood
gui_crew_window_captains_actions_renounce_title_tooltip=You will no longer be captain, and the role will be passed around until a crewmember takes it.
gui_crew_window_captains_actions_pass_title=Pass Captain To
gui_crew_window_captains_actions_pass_title_tooltip=Make the selected crewmember into the Captain.
gui_crew_window_captains_actions_plank=Plank (Make Spectator)
gui_crew_window_captains_actions_plank=Plank (Send to Lobby)
gui_crew_window_captains_actions_plank_tooltip=The player will be returned to the lobby and can't join your crew for a while. (or use /plank {player})
gui_crew_window_captains_actions_make_officer=Make Officer
gui_crew_window_captains_actions_make_officer_tooltip=Make this player an Officer. (or use /officer {player})
@ -523,7 +515,6 @@ gui_progress_time_of_day=Time of day: __1__
gui_runs_play=Crews
gui_runs_ongoing_runs=Ongoing Crews
gui_runs_ongoing_runs_helpful_tip=To join a crew, first select it in the table below.
gui_runs_ongoing_runs_spectate=Spectate
gui_runs_ongoing_runs_join_crew=Join Crew
gui_runs_ongoing_runs_return_to_lobby=Return to Lobby
gui_runs_ongoing_runs_hop_on_board=Hop on board.
@ -632,7 +623,7 @@ cmd_explain_classinfo={class name} returns the definition of the named class.
# cmd_explain_classinfofull={class name} returns detailed definition of the named class.
cmd_explain_ccolor=is an extension to the built-in /color command, with more colors.
cmd_explain_fixpower=attempts to reconnect power poles between deck and holds
cmd_explain_plank={player} is a captain command to remove a player by making them a spectator.
cmd_explain_plank={player} is a captain command to remove a player from the crew and send them to the lobby.
cmd_explain_officer={player} is a captain command to make a player into an officer, or remove them as one.
cmd_explain_undock=is a captain command to undock the ship.
cmd_explain_tax=is a captain command to take a quarter of all coins, plus other game-critical items from the crew, into your inventory.
@ -640,8 +631,5 @@ cmd_explain_clear_north_tanks=Clear ship's north fluid storage tanks on deck and
cmd_explain_clear_south_tanks=Clear ship's south fluid storage tanks on deck and all holds.
cmd_explain_dev=is a dev command.
gui_crew_window_spectator_controls=Spectator Controls
gui_crew_window_spectator_goto_surface=Go to Surface
market_description_purchase_attack_upgrade=__1__% damage upgrade to all weapons and turrets.
market_event_attack_upgrade_purchased=__1__ bought a __2__% damage upgrade to all weapons and turrets.

View File

@ -1761,10 +1761,7 @@ local function event_on_player_joined_game(event)
local spawnpoint = Common.lobby_spawnpoint
local surface = game.surfaces[CoreData.lobby_surface_name]
player.character.teleport(
surface.find_non_colliding_position("character", spawnpoint, 32, 0.5) or spawnpoint,
surface
)
player.teleport(surface.find_non_colliding_position("character", spawnpoint, 32, 0.5) or spawnpoint, surface)
Permissions.update_privileges(player)
if not player.name then
@ -1883,12 +1880,6 @@ local function event_on_pre_player_left_game(event)
break
end
end
for _, id in pairs(memory.spectatorplayerindices) do
if player.index == id then
Crew.leave_spectators(player, true)
break
end
end
global_memory.last_players_health[event.player_index] = nil
end

View File

@ -565,7 +565,7 @@ commands.add_command("remove_classes", { "pirates.cmd_explain_dev" }, function(c
memory.available_classes_pool = Classes.initial_class_pool()
memory.class_entry_count = 0
local players = Common.crew_get_crew_members_and_spectators()
local players = Common.crew_get_crew_members()
for _, player in pairs(players) do
Gui.classes.full_update(player, true)

View File

@ -149,12 +149,7 @@ function Public.activecrewcount()
local count = 0
for _, id in pairs(memory.crewplayerindices) do
local player = game.players[id]
if
player
and player.valid
and (not Utils.contains(global_memory.afk_player_indices, player.index))
and (not Utils.contains(memory.spectatorplayerindices, player.index))
then
if player and player.valid and (not Utils.contains(global_memory.afk_player_indices, player.index)) then
count = count + 1
end
end
@ -1012,52 +1007,6 @@ function Public.crew_get_crew_members()
return playerlist
end
function Public.crew_get_crew_members_and_spectators()
local memory = Memory.get_crew_memory()
if not Public.is_id_valid(memory.id) then
return {}
end
local playerlist = {}
for _, id in pairs(memory.crewplayerindices) do
local player = game.players[id]
if player and player.valid then
playerlist[#playerlist + 1] = player
end
end
for _, id in pairs(memory.spectatorplayerindices) do
local player = game.players[id]
if player and player.valid then
playerlist[#playerlist + 1] = player
end
end
return playerlist
end
function Public.is_spectator(player)
local global_memory = Memory.get_global_memory()
local previous_id = global_memory.working_id
local player_crew_id = Public.get_id_from_force_name(player.force.name)
if not player_crew_id then
return false
end
Memory.set_working_id(player_crew_id)
local memory = Memory.get_crew_memory()
local spectating = false
for _, playerindex in pairs(memory.spectatorplayerindices) do
if player.index == playerindex then
spectating = true
break
end
end
Memory.set_working_id(previous_id)
return spectating
end
function Public.crew_get_nonafk_crew_members()
local global_memory = Memory.get_global_memory()
local memory = Memory.get_crew_memory()

View File

@ -275,167 +275,6 @@ function Public.choose_crew_members()
return crew_members
end
function Public.join_spectators(player, crewid)
if crewid == 0 then
return
end
Memory.set_working_id(crewid)
local memory = Memory.get_crew_memory()
local force = memory.force
if not (force and force.valid and Common.validate_player(player)) then
return
end
local surface = game.surfaces[CoreData.lobby_surface_name]
local adventuring = false
local spectating = false
if memory.crewstatus and memory.crewstatus == enum.ADVENTURING then
for _, playerindex in pairs(memory.crewplayerindices) do
if player.index == playerindex then
adventuring = true
end
end
for _, playerindex in pairs(memory.spectatorplayerindices) do
if player.index == playerindex then
spectating = true
end
end
end
if spectating then
return
end
if adventuring then
local char = player.character
if char and char.valid then
local p = char.position
-- local surface_name = char.surface.name
if p then
Common.notify_force(force, { "pirates.crew_to_spectator", player.name })
-- Server.to_discord_embed_raw(CoreData.comfy_emojis.feel .. '[' .. memory.name .. '] ' .. message)
end
-- if p then
-- Common.notify_force(force, message .. ' to become a spectator.' .. ' [gps=' .. Math.ceil(p.x) .. ',' .. Math.ceil(p.y) .. ',' .. surface_name ..']')
-- -- Server.to_discord_embed_raw(CoreData.comfy_emojis.feel .. '[' .. memory.name .. '] ' .. message)
-- end
local player_surface_type = SurfacesCommon.decode_surface_name(player.surface.name).type
local boat_surface_type = SurfacesCommon.decode_surface_name(memory.boat.surface_name).type
if not memory.temporarily_logged_off_player_data then
memory.temporarily_logged_off_player_data = {}
end
memory.temporarily_logged_off_player_data[player.index] = {
on_island = (player_surface_type == Surfaces.enum.ISLAND),
on_boat = (player_surface_type == boat_surface_type)
and Boats.on_boat(memory.boat, player.character.position),
surface_name = player.surface.name,
position = player.character.position,
tick = game.tick,
}
Common.temporarily_store_logged_off_character_items(player)
char.die(memory.force_name)
player.set_controller({ type = defines.controllers.spectator })
else
Common.notify_force(force, { "pirates.crew_to_spectator", player.name })
-- Server.to_discord_embed_raw(CoreData.comfy_emojis.feel .. '[' .. memory.name .. '] ' .. message)
player.set_controller({ type = defines.controllers.spectator })
end
local c = surface.create_entity({
name = "character",
position = surface.find_non_colliding_position("character", Common.lobby_spawnpoint, 32, 0.5)
or Common.lobby_spawnpoint,
force = Common.lobby_force_name,
})
player.associate_character(c)
player.set_controller({ type = defines.controllers.spectator })
memory.crewplayerindices = Utils.ordered_table_with_values_removed(memory.crewplayerindices, player.index)
Roles.player_left_so_redestribute_roles(player)
else
local c = player.character
player.set_controller({ type = defines.controllers.spectator })
player.teleport(memory.spawnpoint, game.surfaces[memory.boat.surface_name])
player.force = force
player.associate_character(c)
Common.notify_force(force, { "pirates.lobby_to_spectator", player.name })
Common.notify_lobby({ "pirates.lobby_to_spectator_2", player.name, memory.name })
end
memory.spectatorplayerindices[#memory.spectatorplayerindices + 1] = player.index
if not _DEBUG then
memory.tempbanned_from_joining_data[player.index] = game.tick
end
if #Common.crew_get_crew_members() == 0 then
local exists_disband_tick = memory.crew_disband_tick and memory.crew_disband_tick > game.tick
if Common.autodisband_hours and not exists_disband_tick and Server.get_current_time() then
memory.crew_disband_tick = game.tick + Common.autodisband_hours * 60 * 60 * 60
end
end
if not memory.difficulty_votes then
memory.difficulty_votes = {}
end
memory.difficulty_votes[player.index] = nil
end
function Public.leave_spectators(player, quiet)
quiet = quiet or false
local memory = Memory.get_crew_memory()
local surface = game.surfaces[CoreData.lobby_surface_name]
if not Common.validate_player(player) then
return
end
if not quiet then
Common.notify_force(player.force, { "pirates.spectator_to_lobby", player.name })
end
local chars = player.get_associated_characters()
if #chars > 0 then
player.set_controller({ type = defines.controllers.character, character = chars[1] })
player.character.teleport(chars[1].position, surface)
else
player.set_controller({ type = defines.controllers.god })
player.teleport(
surface.find_non_colliding_position("character", Common.lobby_spawnpoint, 32, 0.5)
or Common.lobby_spawnpoint,
surface
)
player.create_character()
end
memory.spectatorplayerindices = Utils.ordered_table_with_values_removed(memory.spectatorplayerindices, player.index)
if #Common.crew_get_crew_members() == 0 then
local exists_disband_tick = memory.crew_disband_tick and memory.crew_disband_tick > game.tick
if Common.autodisband_hours and not exists_disband_tick and Server.get_current_time() then
memory.crew_disband_tick = game.tick + Common.autodisband_hours * 60 * 60 * 60
end
end
player.force = Common.lobby_force_name
end
function Public.join_crew(player, rejoin)
local memory = Memory.get_crew_memory()
@ -453,72 +292,41 @@ function Public.join_crew(player, rejoin)
surface = game.surfaces[Common.current_destination().surface_name]
end
-- local adventuring = false
local spectating = false
if memory.crewstatus == enum.ADVENTURING then
-- for _, playerindex in pairs(memory.crewplayerindices) do
-- if player.index == playerindex then adventuring = true end
-- end
for _, playerindex in pairs(memory.spectatorplayerindices) do
if player.index == playerindex then
spectating = true
end
end
end
if spectating then
local chars = player.get_associated_characters()
for _, char in pairs(chars) do
char.destroy()
end
player.teleport(
surface.find_non_colliding_position("character", memory.spawnpoint, 32, 0.5) or memory.spawnpoint,
surface
)
if not (player.character and player.character.valid) then
player.set_controller({ type = defines.controllers.god })
player.create_character()
end
memory.spectatorplayerindices =
Utils.ordered_table_with_values_removed(memory.spectatorplayerindices, player.index)
else
if not (player.character and player.character.valid) then
player.set_controller({ type = defines.controllers.god })
player.create_character()
end
player.force = memory.force
player.force = memory.force
Common.notify_lobby({ "pirates.lobby_to_crew_2", player.name, memory.name })
Common.notify_lobby({ "pirates.lobby_to_crew_2", player.name, memory.name })
player.character.teleport(
surface.find_non_colliding_position("character", memory.spawnpoint, 32, 0.5) or memory.spawnpoint,
surface
)
player.character.teleport(
surface.find_non_colliding_position("character", memory.spawnpoint, 32, 0.5) or memory.spawnpoint,
surface
)
if rejoin then
if memory.temporarily_logged_off_player_data[player.index] then
local rejoin_data = memory.temporarily_logged_off_player_data[player.index]
local rejoin_surface = game.surfaces[rejoin_data.surface_name]
if rejoin then
if memory.temporarily_logged_off_player_data[player.index] then
local rejoin_data = memory.temporarily_logged_off_player_data[player.index]
local rejoin_surface = game.surfaces[rejoin_data.surface_name]
-- If surface where player left the game still exists, place him there.
if rejoin_surface and rejoin_surface.valid then
-- Edge case: if player left the game while he was on the boat, it could be that boat position
-- changed when he left the game vs when he came back.
if not (rejoin_data.on_boat and rejoin_data.on_island) then
player.character.teleport(
rejoin_surface.find_non_colliding_position("character", rejoin_data.position, 32, 0.5)
or memory.spawnpoint,
rejoin_surface
)
end
-- If surface where player left the game still exists, place him there.
if rejoin_surface and rejoin_surface.valid then
-- Edge case: if player left the game while he was on the boat, it could be that boat position
-- changed when he left the game vs when he came back.
if not (rejoin_data.on_boat and rejoin_data.on_island) then
player.character.teleport(
rejoin_surface.find_non_colliding_position("character", rejoin_data.position, 32, 0.5)
or memory.spawnpoint,
rejoin_surface
)
end
Common.give_back_items_to_temporarily_logged_off_player(player)
memory.temporarily_logged_off_player_data[player.index] = nil
end
Common.give_back_items_to_temporarily_logged_off_player(player)
memory.temporarily_logged_off_player_data[player.index] = nil
end
end
@ -665,7 +473,7 @@ function Public.get_unaffiliated_players()
local found = false
for _, id in pairs(global_memory.crew_active_ids) do
Memory.set_working_id(id)
for _, player2 in pairs(Common.crew_get_crew_members_and_spectators()) do
for _, player2 in pairs(Common.crew_get_crew_members()) do
if player == player2 then
found = true
end
@ -689,8 +497,8 @@ function Public.plank(captain, player)
Common.notify_force(player.force, { "pirates.plank", captain.name, player.name })
Public.join_spectators(player, memory.id)
memory.tempbanned_from_joining_data[player.index] = game.tick + 60 * 120
Public.leave_crew(player, true, true)
memory.tempbanned_from_joining_data[player.index] = game.tick + 60 * 60 * 5
return true
else
Common.notify_player_error(player, { "pirates.plank_error_self" })
@ -711,7 +519,7 @@ function Public.disband_crew(donotprint)
end
local id = memory.id
local players = Common.crew_get_crew_members_and_spectators()
local players = Common.crew_get_crew_members()
for _, player in pairs(players) do
if player.controller_type == defines.controllers.editor then
@ -902,7 +710,6 @@ function Public.initialise_crew(accepted_proposal, player_position)
memory.delayed_tasks = {}
memory.buffered_tasks = {}
memory.crewplayerindices = {}
memory.spectatorplayerindices = {}
memory.tempbanned_from_joining_data = {}
memory.destinations = {}
-- memory.temporarily_logged_off_characters = {}

View File

@ -228,10 +228,6 @@ function Public.full_update(player, force_refresh)
button.style.clicked_font_color = black
button.enabled = false
end
if Common.is_spectator(player) then
button.enabled = false
end
else
log("Error: Non-existant label index, here some debug info.")
log(_inspect(class_list_panel_table))

View File

@ -236,7 +236,6 @@ function Public.crew_overall_state_bools(player_index)
local ret = {
adventuring = false,
spectating = false,
created_crew = false,
proposing = false,
sloops_full = false,
@ -250,11 +249,6 @@ function Public.crew_overall_state_bools(player_index)
ret.adventuring = true
end
end
for _, playerindex in pairs(memory.spectatorplayerindices) do
if player_index == playerindex then
ret.spectating = true
end
end
end
if memory.crewstatus == nil then
for _, crewid in pairs(global_memory.crew_active_ids) do

View File

@ -106,43 +106,7 @@ function Public.toggle_window(player)
flow3.style.font_color = { r = 0.10, g = 0.10, b = 0.10 }
flow3.tooltip = { "pirates.gui_crew_window_buttons_quit_crew_tooltip" }
-- Runs window already has a button to leave spectators.
-- flow3 =
-- flow2.add(
-- {
-- name = 'crewmember_leave_spectators',
-- type = 'button',
-- caption = {'pirates.gui_crew_window_buttons_quit_spectators'}
-- }
-- )
-- flow3.style.minimal_width = 95
-- flow3.style.font = 'default-bold'
-- flow3.style.font_color = {r = 0.10, g = 0.10, b = 0.10}
flow3 = flow2.add({
name = "spectator_join_crew",
type = "button",
caption = { "pirates.gui_crew_window_buttons_join_crew" },
})
flow3.style.minimal_width = 95
flow3.style.font = "default-bold"
flow3.style.font_color = { r = 0.10, g = 0.10, b = 0.10 }
-- Disabled spectators for now... might not play well with maze world
-- flow3 =
-- flow2.add(
-- {
-- name = 'crewmember_join_spectators',
-- type = 'button',
-- caption = {'pirates.gui_crew_window_buttons_join_spectators'}
-- }
-- )
-- flow3.style.minimal_width = 95
-- flow3.style.font = 'default-bold'
-- flow3.style.font_color = {r = 0.10, g = 0.10, b = 0.10}
-- flow3.tooltip = {'pirates.gui_crew_window_buttons_join_spectators_tooltip'}
--*** MEMBERS AND SPECTATORS ***--
--*** MEMBERS ***--
flow2 = GuiCommon.flow_add_section(flow, "members", { "pirates.gui_crew_window_crewmembers" })
@ -163,35 +127,6 @@ function Public.toggle_window(player)
flow3.style.font_color = { r = 0.10, g = 0.10, b = 0.10 }
flow3.tooltip = { "pirates.gui_crew_window_crewmembers_resign_as_officer_tooltip" }
flow2 = GuiCommon.flow_add_section(flow, "spectators", { "pirates.gui_crew_window_spectators" })
flow3 = flow2.add({
name = "spectators_listbox",
type = "list-box",
})
flow3.style.margin = 2
flow3.style.maximal_height = 150
--*** SPECTATOR TOOLS ***--
flow2 = GuiCommon.flow_add_section(flow, "spectator_controls", { "pirates.gui_crew_window_spectator_controls" })
flow3 = flow2.add({
name = "spectator_surfaces_listbox",
type = "list-box",
})
flow3.style.margin = 5
flow3.style.maximal_height = 150
flow3 = flow2.add({
name = "spectator_goto_surface",
type = "button",
caption = { "pirates.gui_crew_window_spectator_goto_surface" },
})
flow3.style.minimal_width = 95
flow3.style.font = "default-bold"
flow3.style.font_color = { r = 0.10, g = 0.10, b = 0.10 }
--*** DIFFICULTY VOTE ***--
flow2 = GuiCommon.flow_add_section(flow, "difficulty_vote", { "pirates.gui_crew_window_vote_for_difficulty" })
@ -356,26 +291,23 @@ function Public.full_update(player)
--*** WHAT TO SHOW ***--
flow.difficulty_vote.visible = memory.overworldx and memory.overworldx == 0 and not playercrew_status.spectating
flow.difficulty_vote.visible = memory.overworldx and memory.overworldx == 0
flow.members.body.officer_resign.visible = Common.is_officer(player.index) and not playercrew_status.spectating
flow.members.body.officer_resign.visible = Common.is_officer(player.index)
local selected_player_index = get_selected_player_index(flow)
local other_player_selected = flow.members.body.members_listbox.selected_index ~= 0
and selected_player_index ~= player.index
flow.captain.visible = Common.is_captain(player) and not playercrew_status.spectating
flow.undock_tip.visible = Common.is_captain(player) and not playercrew_status.spectating
flow.captain.visible = Common.is_captain(player)
flow.undock_tip.visible = Common.is_captain(player)
flow.captain.body.capn_pass.visible = other_player_selected
flow.captain.body.capn_plank.visible = other_player_selected
flow.captain.body.make_officer.visible = other_player_selected
and (not Common.is_officer(selected_player_index))
and not playercrew_status.spectating
flow.captain.body.unmake_officer.visible = other_player_selected
and Common.is_officer(selected_player_index)
and not playercrew_status.spectating
flow.captain.body.make_officer.visible = other_player_selected and (not Common.is_officer(selected_player_index))
flow.captain.body.unmake_officer.visible = other_player_selected and Common.is_officer(selected_player_index)
-- flow.captain.body.capn_undock_normal.visible = boat and boat.state and ((boat.state == boats.enum_state.LANDED) or (boat.state == Boats.enum_state.APPROACHING) or (boat.state == Boats.enum_state.DOCKED))
@ -393,34 +325,11 @@ function Public.full_update(player)
end
flow.members.visible = true
flow.spectators.visible = (#memory.spectatorplayerindices > 0)
-- flow.crew_age.visible = true
-- -- flow.crew_age.visible = memory.mode and memory.mode == 'speedrun'
-- flow.crew_difficulty.visible = true
flow.spectator_controls.visible = playercrew_status.spectating
local count = 0
if playercrew_status.spectating then
for _, v in pairs(memory.crewplayerindices) do
if Common.validate_player(game.players[v]) then
count = count + 1
end
end
end
flow.membership_buttons.spectator_join_crew.visible = playercrew_status.spectating
and (count < memory.capacity)
and not memory.run_is_private
flow.membership_buttons.leave_crew.visible = playercrew_status.adventuring
-- flow.membership_buttons.crewmember_join_spectators.visible = playercrew_status.adventuring
-- flow.membership_buttons.leave_spectators.visible = playercrew_status.spectating
flow.membership_buttons.spectator_join_crew.visible = flow.membership_buttons.spectator_join_crew.visible
and not (
memory.tempbanned_from_joining_data[player.index]
and game.tick < memory.tempbanned_from_joining_data[player.index] + Common.ban_from_rejoining_crew_ticks
)
--== UPDATE CONTENT ==--
@ -456,56 +365,6 @@ function Public.full_update(player)
flow.members.header.caption = { "pirates.gui_crew_window_crew_count", (#memory.crewplayerindices or 0) }
end
if flow.spectators.visible then
local wrappedspectators = {}
for _, index in pairs(memory.spectatorplayerindices) do
local player2 = game.players[index]
wrappedspectators[#wrappedspectators + 1] = {
"pirates.crewmember_displayform",
index,
player2.color.r,
player2.color.g,
player2.color.b,
player2.name,
"",
}
end
GuiCommon.update_listbox(flow.spectators.body.spectators_listbox, wrappedspectators)
end
if flow.spectator_controls.visible then
local surfaces = {
{
name = "Crow's Nest",
surface_name = SurfacesCommon.encode_surface_name(memory.id, 0, Surfaces.enum.CROWSNEST, nil),
},
}
for i = 1, memory.hold_surface_count do
local name
if memory.hold_surface_count == 1 then
name = "Hold"
else
name = "Hold " .. i
end
table.insert(surfaces, { name = name, surface_name = Hold.get_hold_surface_name(i) })
end
if Common.current_destination() then
table.insert(
surfaces,
{ name = "Current Destination", surface_name = Common.current_destination().surface_name }
)
end
local wrapped_surfaces = {}
for i, surface in ipairs(surfaces) do
wrapped_surfaces[#wrapped_surfaces + 1] = { "", i, ". ", surface.name }
end
GuiCommon.update_listbox(flow.spectator_controls.body.spectator_surfaces_listbox, wrapped_surfaces)
end
-- if flow.captain.body.capn_undock_normal.visible then
-- flow.captain.body.capn_undock_normal.enabled = ((boat.state == Boats.enum_state.LANDED) and Common.query_can_pay_cost_to_leave()) or (boat.state == Boats.enum_state.DOCKED)
-- end
@ -532,26 +391,6 @@ function Public.click(event)
local memory = Memory.get_crew_memory()
-- if eventname == 'crewmember_join_spectators' then
-- Crew.join_spectators(player, memory.id)
-- return
-- end
-- if eventname == 'crewmember_leave_spectators' then
-- Crew.leave_spectators(player)
-- return
-- end
if eventname == "spectator_join_crew" then
Crew.join_crew(player)
if memory.run_is_protected and (not Roles.captain_exists()) then
Common.notify_player_expected(player, { "pirates.player_joins_protected_run_with_no_captain" })
Common.notify_player_expected(player, { "pirates.create_new_crew_tip" })
end
return
end
if eventname == "leave_crew" then
Crew.leave_crew(player, true)
return
@ -655,38 +494,6 @@ function Public.click(event)
Crew.plank(player, game.players[other_id])
return
end
if eventname == "spectator_goto_surface" then
local selected_index = flow.spectator_controls.body.spectator_surfaces_listbox.selected_index
if selected_index ~= 0 then
local surfaces = {
SurfacesCommon.encode_surface_name(memory.id, 0, Surfaces.enum.CROWSNEST, nil),
}
for i = 1, memory.hold_surface_count do
table.insert(surfaces, Hold.get_hold_surface_name(i))
end
if Common.current_destination() then
table.insert(surfaces, Common.current_destination().surface_name)
end
local target_surface = game.surfaces[surfaces[selected_index]]
if target_surface then
local position
if selected_index == 1 then -- Crow's Nest
position = { x = memory.overworldx, y = memory.overworldy }
elseif selected_index >= 2 and selected_index < 2 + memory.hold_surface_count then -- Hold
-- local hold_index = selected_index - 1
position = { x = 0, y = 0 }
else
position = memory.boat.position
end
player.teleport(position, target_surface)
end
end
return
end
end
return Public

View File

@ -234,15 +234,6 @@ function Public.toggle_window(player)
direction = "horizontal",
})
flow4 = flow3.add({
name = "join_spectators",
type = "button",
caption = { "pirates.gui_runs_ongoing_runs_spectate" },
})
flow4.style.minimal_width = 95
flow4.style.font = "default-bold"
flow4.style.font_color = { r = 0.10, g = 0.10, b = 0.10 }
flow4 = flow3.add({
name = "join_crew",
type = "button",
@ -252,15 +243,6 @@ function Public.toggle_window(player)
flow4.style.font = "default-bold"
flow4.style.font_color = { r = 0.10, g = 0.10, b = 0.10 }
flow4 = flow3.add({
name = "leave_spectators",
type = "button",
caption = { "pirates.gui_runs_ongoing_runs_return_to_lobby" },
})
flow4.style.minimal_width = 95
flow4.style.font = "default-bold"
flow4.style.font_color = { r = 0.10, g = 0.10, b = 0.10 }
flow3 = flow2.add({
name = "wait_to_join",
type = "label",
@ -516,20 +498,14 @@ function Public.full_update(player)
local selected_crew = selected_index ~= 0
and global_memory.crew_memories[tonumber(ongoing_runs.body.ongoing_runs_listbox.get_item(selected_index)[2])]
if playercrew_status.leaving or playercrew_status.adventuring or playercrew_status.spectating then
if playercrew_status.leaving or playercrew_status.adventuring then
selected_crew = false
end
local can_join = selected_crew and selected_crew.crewstatus == Crew.enum.ADVENTURING
ongoing_runs.body.helpful_tip.visible = not (
playercrew_status.leaving
or playercrew_status.adventuring
or playercrew_status.spectating
)
ongoing_runs.body.flow_buttons.visible = can_join or playercrew_status.spectating
ongoing_runs.body.flow_buttons.join_spectators.visible = can_join
ongoing_runs.body.flow_buttons.leave_spectators.visible = playercrew_status.spectating
ongoing_runs.body.helpful_tip.visible = not (playercrew_status.leaving or playercrew_status.adventuring)
ongoing_runs.body.flow_buttons.visible = can_join
ongoing_runs.body.flow_buttons.join_crew.visible = can_join
and selected_crew
and not (
@ -643,22 +619,6 @@ function Public.click(event)
local global_memory = Memory.get_global_memory()
-- local memory = Memory.get_crew_memory()
if eventname == "join_spectators" then
local listbox = flow.ongoing_runs.body.ongoing_runs_listbox
-- It was observed that "listbox.get_item(listbox.selected_index)" can produce "Index out of range error"
-- This is to prevent that error.
if listbox.selected_index >= 1 and listbox.selected_index <= #listbox.items then
Crew.join_spectators(player, tonumber(listbox.get_item(listbox.selected_index)[2]))
end
return
end
if eventname == "leave_spectators" then
Crew.leave_spectators(player)
return
end
if eventname == "join_crew" then
local listbox = flow.ongoing_runs.body.ongoing_runs_listbox

View File

@ -83,10 +83,6 @@ local function on_init()
game.reset_time_played()
-- local spectator = game.create_force('spectator')
-- local spectator_permissions = game.permissions.create_group('spectator')
-- spectator_permissions.set_allows_action(defines.input_action.start_walking,false)
Autostash.insert_into_furnace(true)
-- Autostash.insert_into_wagon(true)
Autostash.bottom_button(true)

View File

@ -45,7 +45,6 @@ function Public.fallthrough_crew_memory() --could make this a metatable, but met
force_name = "player", -- should match Common.lobby_force_name
boat = {},
destinations = {},
spectatorplayerindices = {},
crewplayerindices = {},
--[[boat = {
type = nil,

View File

@ -293,18 +293,10 @@ function Public.progress_to_destination(destination_index)
memory.extra_time_at_sea = 0
if old_type == Surfaces.enum.SEA or old_type == Surfaces.enum.CHANNEL or old_type == Surfaces.enum.DOCK then
-- move over anyone who was left behind, such as dead and spectating players
-- move over anyone who was left behind, such as dead players
for _, player in pairs(game.connected_players) do
if Common.validate_player_and_character(player) then
if type == Surfaces.enum.ISLAND and player.controller_type == defines.controllers.spectator then
if player.surface == oldsurface then --avoid moving players in hold etc
-- put them at a nice viewing position:
player.character.teleport(
{ x = memory.spawnpoint.x + 120, y = memory.spawnpoint.y },
newsurface
)
end
elseif player.surface == oldsurface then
if player.surface == oldsurface then
player.character.teleport(memory.spawnpoint, newsurface)
end
end

View File

@ -88,8 +88,6 @@ function Public.tag_text(player)
if Common.is_id_valid(memory.id) and Common.is_captain(player) then
tags[#tags + 1] = "Cap'n"
elseif player.controller_type == defines.controllers.spectator then
tags[#tags + 1] = "Spectating"
elseif Common.is_officer(player.index) then
tags[#tags + 1] = "Officer"
end