summaryrefslogtreecommitdiff
path: root/areas/hud.lua
diff options
context:
space:
mode:
authorVanessa Ezekowitz <vanessaezekowitz@gmail.com>2016-04-01 20:02:19 -0400
committerVanessa Ezekowitz <vanessaezekowitz@gmail.com>2016-04-01 21:09:33 -0400
commitda66780a569712c23ae4f2996cfb4608a9f9d69d (patch)
tree217556029a78bc23ad4564720afc86de97228a04 /areas/hud.lua
parent615b22df4d423aded3613db7716943a2f389b047 (diff)
downloaddreambuilder_modpack-da66780a569712c23ae4f2996cfb4608a9f9d69d.tar
dreambuilder_modpack-da66780a569712c23ae4f2996cfb4608a9f9d69d.tar.gz
dreambuilder_modpack-da66780a569712c23ae4f2996cfb4608a9f9d69d.tar.bz2
dreambuilder_modpack-da66780a569712c23ae4f2996cfb4608a9f9d69d.tar.xz
dreambuilder_modpack-da66780a569712c23ae4f2996cfb4608a9f9d69d.zip
copy all standard Dreambuilder mods in from the old subgame
(exactly as last supplied there, updates to these mods will follow later)
Diffstat (limited to 'areas/hud.lua')
-rw-r--r--areas/hud.lua46
1 files changed, 46 insertions, 0 deletions
diff --git a/areas/hud.lua b/areas/hud.lua
new file mode 100644
index 0000000..4908b92
--- /dev/null
+++ b/areas/hud.lua
@@ -0,0 +1,46 @@
+-- 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 areaStrings = {}
+ for id, area in pairs(areas:getAreasAtPos(pos)) do
+ table.insert(areaStrings, ("%s [%u] (%s%s)")
+ :format(area.name, id, area.owner,
+ area.open and ":open" or ""))
+ end
+ local areaString = "Areas:"
+ if #areaStrings > 0 then
+ areaString = areaString.."\n"..
+ table.concat(areaStrings, "\n")
+ end
+ local hud = areas.hud[name]
+ if not hud then
+ hud = {}
+ areas.hud[name] = hud
+ hud.areasId = player:hud_add({
+ hud_elem_type = "text",
+ name = "Areas",
+ number = 0xFFFFFF,
+ position = {x=0, y=1},
+ offset = {x=8, y=-8},
+ text = areaString,
+ scale = {x=200, y=60},
+ alignment = {x=1, y=-1},
+ })
+ hud.oldAreas = areaString
+ return
+ elseif hud.oldAreas ~= areaString then
+ player:hud_change(hud.areasId, "text", areaString)
+ hud.oldAreas = areaString
+ end
+ end
+end)
+
+minetest.register_on_leaveplayer(function(player)
+ areas.hud[player:get_player_name()] = nil
+end)
+