mirror of
https://github.com/minetest-mods/areas.git
synced 2025-10-30 20:45:31 +01:00
1.2 KiB
1.2 KiB
API Extension
Adding your protections to the HUD
If you are providing an extra protection mod to work in conjunction with the
HUD feature of areas, you can register a callback to add your mod's code to
display your protection's existence.
Registering a handler:
areas.registerHudHandler(handler) --> nil
Handler specification:
handler(pos,area_list) --> new_area_listpos- the position at which to check for protection coverage by your modarea_list- the current list of protected areasnew_area_list- the list of protected areas, updated with your entries
Area list items:
The area list item is a map table identified with an ID, and properties
The ID should be in the format modname: and appended with an identifier for the protection.
Each area list item should be a table with the following properties
owner- (required) the name of the protection ownername- (optional) the name of the area
Example
local myhandler = function(pos,area_list)
local areaowner = find_my_protections(pos)
if areaowner then
arealist["mymodname:first"] = {
name = "Protection name",
owner = areaowner,
}
end
end
areas.register_hud_handler(myhandler)