summaryrefslogtreecommitdiff
path: root/hud.lua
diff options
context:
space:
mode:
authorShadowNinja <shadowninja@minetest.net>2013-11-14 18:25:47 -0500
committerShadowNinja <shadowninja@minetest.net>2013-11-14 18:25:47 -0500
commit1a8efa991661485b32b0c337e1fd1f43506cf16b (patch)
tree13bc2b17d0a470d9a6d51e739dfe79f84edf1e88 /hud.lua
parent7bfe20661d10a8c94c12ef84bb6fe502d4732079 (diff)
Fix possible hud vector error
Diffstat (limited to 'hud.lua')
-rw-r--r--hud.lua49
1 files changed, 26 insertions, 23 deletions
diff --git a/hud.lua b/hud.lua
index d7eea0d..620a13d 100644
--- a/hud.lua
+++ b/hud.lua
@@ -5,29 +5,32 @@ areas.hud = {}
minetest.register_globalstep(function(dtime)
for _, player in pairs(minetest.get_connected_players()) do
local name = player:get_player_name()
- local pos = vector.round(player:getpos())
- local owners = areas:getNodeOwners(pos)
- local ownerString = table.concat(owners, ", ")
- if not areas.hud[name] then
- areas.hud[name] = {}
- areas.hud[name].ownersId = player:hud_add({
- hud_elem_type = "text",
- name = "AreaOwners",
- number = 0xFFFFFF,
- position = {x=0, y=1},
- offset = {x=5, y=-40},
- direction = 0,
- text = "Area owners: "..ownerString,
- scale = {x=200, y=40},
- alignment = {x=1, y=1},
- })
- areas.hud[name].oldOwners = ownerString
- return
- end
- if areas.hud[name].oldOwners ~= ownerString then
- player:hud_change(areas.hud[name].ownersId, "text",
- "Area owners: "..ownerString)
- areas.hud[name].oldOwners = ownerString
+ local pos = player:getpos()
+ if pos then
+ pos = vector.round(pos)
+ local owners = areas:getNodeOwners(pos)
+ local ownerString = table.concat(owners, ", ")
+ if not areas.hud[name] then
+ areas.hud[name] = {}
+ areas.hud[name].ownersId = player:hud_add({
+ hud_elem_type = "text",
+ name = "AreaOwners",
+ number = 0xFFFFFF,
+ position = {x=0, y=1},
+ offset = {x=5, y=-40},
+ direction = 0,
+ text = "Area owners: "..ownerString,
+ scale = {x=200, y=40},
+ alignment = {x=1, y=1},
+ })
+ areas.hud[name].oldOwners = ownerString
+ return
+ end
+ if areas.hud[name].oldOwners ~= ownerString then
+ player:hud_change(areas.hud[name].ownersId, "text",
+ "Area owners: "..ownerString)
+ areas.hud[name].oldOwners = ownerString
+ end
end
end
end)