Fix possible hud vector error

This commit is contained in:
ShadowNinja 2013-11-14 18:25:47 -05:00
parent 7bfe20661d
commit 1a8efa9916

49
hud.lua
View File

@ -5,29 +5,32 @@ areas.hud = {}
minetest.register_globalstep(function(dtime) minetest.register_globalstep(function(dtime)
for _, player in pairs(minetest.get_connected_players()) do for _, player in pairs(minetest.get_connected_players()) do
local name = player:get_player_name() local name = player:get_player_name()
local pos = vector.round(player:getpos()) local pos = player:getpos()
local owners = areas:getNodeOwners(pos) if pos then
local ownerString = table.concat(owners, ", ") pos = vector.round(pos)
if not areas.hud[name] then local owners = areas:getNodeOwners(pos)
areas.hud[name] = {} local ownerString = table.concat(owners, ", ")
areas.hud[name].ownersId = player:hud_add({ if not areas.hud[name] then
hud_elem_type = "text", areas.hud[name] = {}
name = "AreaOwners", areas.hud[name].ownersId = player:hud_add({
number = 0xFFFFFF, hud_elem_type = "text",
position = {x=0, y=1}, name = "AreaOwners",
offset = {x=5, y=-40}, number = 0xFFFFFF,
direction = 0, position = {x=0, y=1},
text = "Area owners: "..ownerString, offset = {x=5, y=-40},
scale = {x=200, y=40}, direction = 0,
alignment = {x=1, y=1}, text = "Area owners: "..ownerString,
}) scale = {x=200, y=40},
areas.hud[name].oldOwners = ownerString alignment = {x=1, y=1},
return })
end areas.hud[name].oldOwners = ownerString
if areas.hud[name].oldOwners ~= ownerString then return
player:hud_change(areas.hud[name].ownersId, "text", end
"Area owners: "..ownerString) if areas.hud[name].oldOwners ~= ownerString then
areas.hud[name].oldOwners = ownerString player:hud_change(areas.hud[name].ownersId, "text",
"Area owners: "..ownerString)
areas.hud[name].oldOwners = ownerString
end
end end
end end
end) end)