summaryrefslogtreecommitdiff
path: root/hud.lua
diff options
context:
space:
mode:
authorBremaWeb <brandon@bremaweb.com>2013-11-30 13:23:50 -0600
committerBremaWeb <brandon@bremaweb.com>2013-11-30 13:23:50 -0600
commit81a12e3d38c83eacfce4a3eeaec14724dcdb4c8f (patch)
tree58701772bd01e4ab332a0699cdcf0a3e0bf8e432 /hud.lua
parent6b22f3d60f1b942485ccbb6dc5417fbe65119db9 (diff)
restructured, use Settings interface for config, use protection API
Diffstat (limited to 'hud.lua')
-rw-r--r--hud.lua40
1 files changed, 40 insertions, 0 deletions
diff --git a/hud.lua b/hud.lua
new file mode 100644
index 0000000..f7b58c4
--- /dev/null
+++ b/hud.lua
@@ -0,0 +1,40 @@
+landrush.gstepCount = 0
+landrush.playerHudItems = {}
+
+minetest.register_globalstep(function(dtime)
+ landrush.gstepCount = landrush.gstepCount + dtime
+ if ( landrush.gstepCount > 2 ) then
+ landrush.gstepCount=0
+ local oplayers = minetest.get_connected_players()
+ for _,player in ipairs(oplayers) do
+ local name = player:get_player_name()
+ local sameowner = false
+ owner = landrush.get_owner(player:getpos())
+
+ if ( landrush.playerHudItems[name] ~= nil ) then
+ if ( landrush.playerHudItems[name].lastowner == owner ) then
+ -- same owner as last time don't update the hud
+ sameowner = true
+ end
+ end
+
+ if ( landrush.playerHudItems[name] ~= nil and sameowner == false ) then
+ player:hud_remove(landrush.playerHudItems[name].hud)
+ landrush.playerHudItems[name] = nil
+ end
+
+ if ( owner ~= nil and sameowner == false ) then
+ --minetest.log('action','Redraw hud for '..name)
+ landrush.playerHudItems[name] = {hud = player:hud_add({
+ hud_elem_type = "text",
+ name = "LandOwner",
+ number = 0xFFFFFF,
+ position = {x=.2, y=.98},
+ text="Land Owner: "..owner,
+ scale = {x=200,y=25},
+ alignment = {x=0, y=0},
+ }), lastowner=owner}
+ end
+ end
+ end
+end)