Narrow the gui player lookups

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
This commit is contained in:
bbassie
2026-08-07 15:31:43 +00:00
co-authored by Claude Opus 5
parent 3c0b5069fc
commit 231c3a9ea0
4 changed files with 14 additions and 12 deletions
+3 -3
View File
@@ -61,7 +61,7 @@ local GuiData = {
--- @field element_data table<uint, table<uint, any>>
--- @field player_data table<uint, any>
--- @field force_data table<uint, any>
--- @field global_data table
--- @field global_data table
--- @field [DataKey] any
-- This class has no prototype methods
-- Same as raw but __index ensures the values exist
@@ -99,7 +99,7 @@ function GuiData._metatable.__index(self, key)
local data = self._raw.player_data
return data and data[key.index]
elseif object_name == "LuaForce" then
--- @cast key LuaForce
--- @cast key LuaForce
local data = self._raw.force_data
return data and data[key.index]
else
@@ -172,7 +172,7 @@ local function on_object_destroyed(event)
for _, scope in pairs(registered_scopes) do
local data = scope._raw.element_data
local player_elements = data and data[player_index]
if player_elements then
if data and player_elements then
player_elements[element_index] = nil
if not next(player_elements) then
data[player_index] = nil