Skip to content

Commit

Permalink
Add a warning note and extra check for empty table.
Browse files Browse the repository at this point in the history
  • Loading branch information
Oarcinae committed Oct 23, 2024
1 parent cdc3a23 commit 4e7c9c6
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 2 deletions.
2 changes: 2 additions & 0 deletions changelog.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ Version: 2.1.2
Date: 2024-10-23
Bugfixes:
- Fix spawn controls tab in custom GUI not being re-enabled when GUI is recreated (on mod update for example).
Info:
- Add a warning note explanation when the custom respawn feature is not available.
---------------------------------------------------------------------------------------------------
Version: 2.1.1
Date: 2024-10-23
Expand Down
5 changes: 4 additions & 1 deletion lib/gui_tabs/spawn_controls.lua
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ function CreateSetRespawnLocationButton(player, container)
local respawn_info = storage.player_respawns[player.name][player.surface.name]

if (respawn_info == nil) then
log("ERROR: No respawn info for player: " .. player.name)
AddLabel(container, nil, { "oarc-no-respawn-this-surface" }, my_warning_style)
return
end

Expand Down Expand Up @@ -325,6 +325,9 @@ function SpawnCtrlTabGuiClick(event)
elseif (tags.setting == "teleport_home") then
local surface_name = tags.surface --[[@as string]]
local position = tags.position --[[@as MapPosition]]

--TODO Verify player is still on the same surface, if they leave the GUI open, they can teleport back from any surface.

SafeTeleport(player, game.surfaces[surface_name], position)

-- Accept or reject pending player join requests to a shared base
Expand Down
3 changes: 2 additions & 1 deletion lib/oarc_gui_tabs.lua
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,8 @@ function InitOarcGuiTabs(player)

-- Spawn control tab, enable if player is already spawned
AddOarcGuiTab(player, OARC_SPAWN_CTRL_TAB_NAME)
local spawn_enabled = (storage.player_respawns[player.name] ~= nil) -- TODO: Maybe make a specific state flag or something more explicit?
local player_respawns = storage.player_respawns[player.name]
local spawn_enabled = (player_respawns ~= nil) and (next(player_respawns) ~= nil) -- TODO: Maybe make a specific state flag or something more explicit?
SetOarcGuiTabEnabled(player, OARC_SPAWN_CTRL_TAB_NAME, spawn_enabled)

-- Regrowth control tab
Expand Down
1 change: 1 addition & 0 deletions locale/en/locale.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,7 @@ oarc-shared-spawn-allow-joiners=Allow others to join your base.
oarc-shared-spawn-full=Your base is full! No more players can join.

oarc-set-respawn-loc-header=Respawn Location
oarc-no-respawn-this-surface=You cannot set a custom respawn location on this surface.
oarc-set-respawn-loc-info-surface-label=Current Surface Respawn: __1__ (x=__2__, y=__3__)
oarc-set-respawn-loc=Set Respawn Location
oarc-set-respawn-loc-tooltip=This will set your respawn point to your current location. There is a cooldown before you can change it again. You can only set this on supported surfaces.
Expand Down

0 comments on commit 4e7c9c6

Please sign in to comment.