summaryrefslogtreecommitdiff
path: root/api.lua
diff options
context:
space:
mode:
authorTai @ Flex <dch.tai@gmail.com>2016-11-26 07:20:23 +0000
committerShadowNinja <shadowninja@minetest.net>2016-12-19 16:36:37 +0000
commit6080ff065ea89e899f356ba723ea2467b6d32ccb (patch)
tree7cae444532994bafbb711f18e6b3af48fa3c4bcd /api.lua
parent23f81f6278af2269bb11f41ec424936b05c2655f (diff)
Add API for adding areas to HUD
Diffstat (limited to 'api.lua')
-rw-r--r--api.lua16
1 files changed, 16 insertions, 0 deletions
diff --git a/api.lua b/api.lua
index e8b9c7a..730e96d 100644
--- a/api.lua
+++ b/api.lua
@@ -1,7 +1,23 @@
+local hudHandlers = {}
+
+--- Adds a function as a HUD handler, it will be able to add items to the Areas HUD element.
+function areas:registerHudHandler(handler)
+ table.insert(hudHandlers, handler)
+end
+
+
+function areas:getExternalHudEntries(pos)
+ local areas = {}
+ for _, func in pairs(hudHandlers) do
+ func(pos, areas)
+ end
+ return areas
+end
--- Returns a list of areas that include the provided position.
function areas:getAreasAtPos(pos)
local res = {}
+
if self.store then
local a = self.store:get_areas_for_pos(pos, false, true)
for store_id, store_area in pairs(a) do