Add API for adding areas to HUD

This commit is contained in:
Tai @ Flex
2016-11-26 07:20:23 +00:00
committed by ShadowNinja
parent 23f81f6278
commit 6080ff065e
3 changed files with 71 additions and 0 deletions

16
api.lua
View File

@ -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