From aae52ee55e1e978d3e2e72b8824a728527636fc2 Mon Sep 17 00:00:00 2001 From: danielmartin0 Date: Mon, 23 Sep 2024 14:23:58 +0100 Subject: [PATCH] chat code cleanup --- locale/en/pirates.cfg | 6 ++---- maps/pirates/api_events.lua | 13 ++++++------- maps/pirates/gui/info.lua | 14 +++----------- 3 files changed, 11 insertions(+), 22 deletions(-) diff --git a/locale/en/pirates.cfg b/locale/en/pirates.cfg index e708c497..01bcc33c 100644 --- a/locale/en/pirates.cfg +++ b/locale/en/pirates.cfg @@ -15,8 +15,8 @@ softmod_info_new_players_2=Mine coal and other resources and bring them to the s softmod_info_tips_1=Features of the game that are hard to work out alone softmod_info_tips_2=• The captain (or officers) can steer the boat from the crow's nest by placing 50 rail signals in one of the blue boxes.\n• The quantity on an island is independent of the order in which you break rocks.\n• Passive pollution ramps up over time on each island.\n• Items dropped on the deck are transferred to the cabin when the boat moves for performance reasons.\n• When waiting for the captain's order to set sail, the free power supply is disabled.\n• Productivity modules can't be used in machines.\n• Resources granted to the ship appear in the captain's cabin.\n• Useful commands: /classinfo {classname} command, /plank {player}, /officer {player}, /undock, /ccolor, /clear_north_tanks, /clear_south_tanks, /tax, /reset_password -softmod_info_1_1=v1.6.3 highlights -softmod_info_1_2=• Gameplay further slowed down for small crews.\n• Optional setting for new crews to disable blueprints.\n• Fixed a bug causing large waves.\n• Grace period of 2 minutes on each island before attacks. +softmod_info_1_1=v1.6.1–1.6.5 highlights +softmod_info_1_2=• Gameplay further slowed down for small crews.\n• Optional setting for new crews to disable blueprints.\n• Fixed a bug causing large waves.\n• Grace period of 2 minutes on each island before attacks.\n• Machines now deactivate after several minutes spent waiting at sea. softmod_info_2_1=v1.6.0 highlights softmod_info_2_2=• 7 simultaneous crews supported. Surface loading is paused if other crews are engaged in a fight at sea, or are loading themselves.\n• New runs begin on the top lane so that beginners are more likely to encounter docks.\n• Disconnecting players once again have their items temporarily saved. Items are returned to the crew if players don't reconnect quickly.\n• Island surfaces are now always deleted after the boat leaves, fixing issues with marooned players.\n• Melee classes can no longer hold weapons. New class added.\n• The pause at sea now occurs after the loading time for the next destination.\n• Spectators can now change surfaces.\n• Crew proposal endorsements system removed.\n• Balance tweaks:\n - Most maps now have some unkillable spawners\n - Mining productivity increases naturally with leagues traveled\n - Biter nighttime damage bonus nerfed\n - Tweaks to radioactive islands\n - Kovarex enrichment no longer researched at start of game\n - Land mines only purchasable at docks, and drop your speed when placed\n - Flamers nerf slightly increased\n - 5% weapon and turret damage upgrade available at each island market @@ -29,8 +29,6 @@ thesixthroc_support_toast=Support Pirate Ship at ko-fi.com/thesixthroc softmod_info_body_promote=by thesixthroc softmod_info_body_promote_old2=patreon.com/thesixthroc -softmod_info_body_clicky=Click to dismiss. - separator_1=, diff --git a/maps/pirates/api_events.lua b/maps/pirates/api_events.lua index 65dd4c18..6fc8f75a 100644 --- a/maps/pirates/api_events.lua +++ b/maps/pirates/api_events.lua @@ -2092,10 +2092,7 @@ local function event_on_console_chat(event) local global_memory = Memory.get_global_memory() local player = game.players[event.player_index] - local tag = player.tag - if not tag then - tag = '' - end + local tag = player.tag or '' local color = player.chat_color -- if global.tournament_mode then @@ -2116,11 +2113,13 @@ local function event_on_console_chat(event) end else -- NOTE: For some reason memory.name(or player.name?) can be nil so need this check. It was observed it happened after crew died and resetted, then I said something in lobby before launching new run. That's the only recorded occurence so far. - if memory.name then + if memory.name and player.name then game.forces.player.print(player.name .. tag .. ' [' .. memory.name .. ']: ' .. event.message, color) - else - game.forces.player.print(player.name .. tag .. event.message, color) + elseif player.name then + game.forces.player.print(player.name .. tag .. ': ' .. event.message, color) log('Error (non-critical): memory.name is nil') + else + log('Error (non-critical): player.name is nil') end end end diff --git a/maps/pirates/gui/info.lua b/maps/pirates/gui/info.lua index a74a012d..f26e3e6b 100644 --- a/maps/pirates/gui/info.lua +++ b/maps/pirates/gui/info.lua @@ -173,13 +173,6 @@ function Public.flow_add_info_tab(flow, tab_name) flow3.style.horizontally_stretchable = true flow3.style.horizontal_align = 'center' - flow4 = flow3.add { type = "label", caption = { "pirates.softmod_info_body_clicky" } } - flow4.style.font = 'default-small' - flow4.style.font_color = GuiCommon.friendly_font_color - flow4.style.single_line = false - flow4.style.bottom_margin = 4 - flow4.style.top_margin = 3 - flow.add_tab(tab, contents) return ret @@ -222,16 +215,15 @@ function Public.full_update(player) local flow = player.gui.screen[window_name .. '_piratewindow'] local flow2 = flow - -- warning, if you make these too small, it loses 'Click to dismiss.' -- This is really really dumb, to have to change these manually. But sadly we couldn't get the window to look like it does and also be expandable. if flow2.selected_tab_index == 1 then flow2.style.height = 400 elseif flow2.selected_tab_index == 2 then - flow2.style.height = 550 + flow2.style.height = 500 elseif flow2.selected_tab_index == 3 then - flow2.style.height = 680 + flow2.style.height = 500 elseif flow2.selected_tab_index == 4 then - flow2.style.height = 340 + flow2.style.height = 350 end end