From 931410fcee157b955c6a85b9ceafb334b06d3e5e Mon Sep 17 00:00:00 2001 From: Octav Sandulescu Date: Fri, 21 Aug 2015 18:15:46 +0000 Subject: [PATCH] Unfuck the player_locations sensor. Fixes #14 --- value_sensors/player_locations.lua | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/value_sensors/player_locations.lua b/value_sensors/player_locations.lua index 4b81ca8..4dbdfdd 100644 --- a/value_sensors/player_locations.lua +++ b/value_sensors/player_locations.lua @@ -10,22 +10,18 @@ function sensor:create_ui(owner) style="description_flow_style"} root.add{type="label", caption={self.format_key}} - self.player_list = root.add{type="table", - name="player_list", - colspan=1} + root.add{type="table", name="player_list", colspan=1} end end function sensor:update_ui(owner) - if self.player_list == nil or not self.player_list.valid then return end - for _, p in ipairs(game.players) do - if self.player_list[p.name] == nil then - self.player_list.add{type="label", name=p.name} + if owner[self.name].player_list[p.name] == nil then + owner[self.name].player_list.add{type="label", name=p.name} end local desc = string.format("%s @(%d, %d on %s)", p.name, p.position.x, p.position.y, p.surface.name) - self.player_list[p.name].caption = desc + owner[self.name].player_list[p.name].caption = desc end end