Skip to content

Commit 5508d6b

Browse files
committedMay 6, 2019
Prevent crash from set_filter before GUI created
Also adds a remote call `get_active_filter` to return a player's current active filter without changing it. Ref: #109
1 parent 01b86df commit 5508d6b

File tree

3 files changed

+20
-1
lines changed

3 files changed

+20
-1
lines changed
 

‎changelog.txt

+7
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,11 @@
11
---------------------------------------------------------------------------------------------------
2+
Version: 0.8.13
3+
Date: 2019-05-06
4+
Bugfixes:
5+
- Prevent crashing from trying to set the active filter before the YARM GUI is created.
6+
Features:
7+
- Add a remote call `get_active_filter(player_name_or_index)` that returns the given player's active filter without changing it (avoiding the need to call `set_filter` twice).
8+
---------------------------------------------------------------------------------------------------
29
Version: 0.8.12
310
Date: 2019-05-02
411
Bugfixes:

‎remote.lua

+7
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,13 @@ function interface.reset_player(player_name_or_index)
2424
player_data.remote_viewer = nil
2525
end
2626

27+
function interface.get_current_filter(player_name_or_index)
28+
local player = game.players[player_name_or_index]
29+
local player_data = global.player_data[player.index]
30+
31+
return player_data.active_filter or 'none'
32+
end
33+
2734
function interface.set_filter(player_name_or_index, new_filter)
2835
local player = game.players[player_name_or_index]
2936
local player_data = global.player_data[player.index]

‎resmon.lua

+6-1
Original file line numberDiff line numberDiff line change
@@ -819,7 +819,12 @@ end
819819

820820

821821
function resmon.update_ui_filter_buttons(player, active_filter)
822-
local buttons_container = mod_gui.get_frame_flow(player).YARM_root.buttons
822+
-- rarely, it might be possible to arrive here before the YARM GUI gets created
823+
local root = mod_gui.get_frame_flow(player).YARM_root
824+
-- in that case, leave it for a later update_ui call.
825+
if not root or not root.valid then return end
826+
827+
local buttons_container = root.buttons
823828
for filter_name, _ in pairs(resmon.filters) do
824829
local is_active_filter = filter_name == active_filter
825830

0 commit comments

Comments
 (0)
Please sign in to comment.