summaryrefslogtreecommitdiff
path: root/hud.lua
diff options
context:
space:
mode:
authorShadowNinja <noreply@gmail.com>2013-09-26 10:30:36 -0400
committerShadowNinja <noreply@gmail.com>2013-09-26 10:30:36 -0400
commit0c20a1b616fb1bc72e6db9fad061b12ee044602a (patch)
tree6b249b66049ff045756ec850436f1ee7df6271ba /hud.lua
parent17b32663b76428f84937ab79fab38259e6a1a831 (diff)
Show area owners on the hud (inspired by landrush)
Diffstat (limited to 'hud.lua')
-rw-r--r--hud.lua38
1 files changed, 38 insertions, 0 deletions
diff --git a/hud.lua b/hud.lua
new file mode 100644
index 0000000..d7eea0d
--- /dev/null
+++ b/hud.lua
@@ -0,0 +1,38 @@
+-- This is inspired by the landrush mod by Bremaweb
+
+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
+ end
+ end
+end)
+
+minetest.register_on_leaveplayer(function(player)
+ areas.hud[player:get_player_name()] = nil
+end)
+