parent
fe79ecb26b
commit
8e18acb929
|
@ -76,7 +76,7 @@ The game includes the mods from the default [minetest_game](https://github.com/m
|
|||
* [playeranim][] ([BSD 2-Clause][lic.playeranim]) - version [0ca8e5a Git][ver.playeranim] *2016-12-07*
|
||||
* [wardrobe][] ([WTFPL][lic.wardrobe]) -- version: [1.1-2-c48b011 Git][ver.wardrobe] *2015-05-21*
|
||||
* protection/
|
||||
* [areas][] ([LGPL][lic.areas]) -- version [67507c7 Git][ver.areas] *2016-06-19* ***UPDT***
|
||||
* [areas][] ([LGPL][lic.areas]) -- version [6080ff0 Git][ver.areas] *2016-11-25*
|
||||
* [simple_protection][] ([WTFPL][lic.simple_protection]) -- version [c822e56 Git][ver.simple_protection] *2016-08-21* ***UPDT***
|
||||
* sound/
|
||||
* [ambience][ambience_ultralite] ([WTFPL][lic.ambience_ultralite.1] / [CC-BY / CC-BY-SA / CC-BY-NC-SA / CC0][lic.ambience_ultralite.2]) -- version: 0.36
|
||||
|
@ -350,7 +350,7 @@ The game includes the mods from the default [minetest_game](https://github.com/m
|
|||
[ver.3d_armor]: https://github.com/stujones11/minetest-3d_armor/tree/793c748
|
||||
[ver.adv_spawning]: https://github.com/sapier/adv_spawning/tree/ec41aa9
|
||||
[ver.antum]: https://github.com/AntumDeluge/mtmp-antum/tree/4477d40
|
||||
[ver.areas]: https://github.com/ShadowNinja/areas/tree/67507c7
|
||||
[ver.areas]: https://github.com/ShadowNinja/areas/tree/6080ff0
|
||||
[ver.awards]: https://github.com/minetest-mods/awards/tree/096fe16
|
||||
[ver.bedrock2]: http://repo.or.cz/minetest_bedrock2.git/tree/0378b61
|
||||
[ver.character_creator]: https://github.com/Rui-Minetest/character_creator/tree/6a0e6aa
|
||||
|
|
|
@ -7,7 +7,7 @@ Configuration
|
|||
|
||||
If you wish to specify configuration options, such as whether players are
|
||||
allowed to protect their own areas with the `protect` command (disabled by
|
||||
default), you should check settings.lua and set the appropriate settings in your
|
||||
default), you should check config.lua and set the appropriate settings in your
|
||||
server's configuration file (probably `minetest.conf`).
|
||||
|
||||
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -0,0 +1,45 @@
|
|||
Areas mod API
|
||||
===
|
||||
|
||||
API list
|
||||
---
|
||||
|
||||
* `areas.registerHudHandler(handler)` - Registers a handler to add items to the Areas HUD. See [HUD](#hud).
|
||||
|
||||
|
||||
HUD
|
||||
---
|
||||
|
||||
If you are making a protection mod or a similar mod that adds invisible regions
|
||||
to the world, and you would like then to show up in the areas HUD element, you
|
||||
can register a callback to show your areas.
|
||||
|
||||
HUD handler specification:
|
||||
|
||||
* `handler(pos, list)`
|
||||
* `pos` - The position to check.
|
||||
* `list` - The list of area HUD elements, this should be modified in-place.
|
||||
|
||||
The area list item is a table containing a list of tables with the following fields:
|
||||
|
||||
* `id` - An identifier for the area. This should be a unique string in the format `mod:id`.
|
||||
* `name` - The name of the area.
|
||||
* `owner` - The player name of the region owner, if any.
|
||||
|
||||
All of the fields are optional but at least one of them must be set.
|
||||
|
||||
### Example
|
||||
|
||||
local function areas_hud_handler(pos, areas)
|
||||
local val = find_my_protection(pos)
|
||||
|
||||
if val then
|
||||
table.insert(areas, {
|
||||
id = "mod:"..val.id,
|
||||
name = val.name,
|
||||
owner = val.owner,
|
||||
})
|
||||
end
|
||||
end
|
||||
|
||||
areas:registerHudHandler(areas_hud_handler)
|
|
@ -7,11 +7,21 @@ minetest.register_globalstep(function(dtime)
|
|||
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
|
||||
|
||||
for i, area in pairs(areas:getExternalHudEntries(pos)) do
|
||||
local str = ""
|
||||
if area.name then str = area.name .. " " end
|
||||
if area.id then str = str.."["..area.id.."] " end
|
||||
if area.owner then str = str.."("..area.owner..")" end
|
||||
table.insert(areaStrings, str)
|
||||
end
|
||||
|
||||
local areaString = "Areas:"
|
||||
if #areaStrings > 0 then
|
||||
areaString = areaString.."\n"..
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
|
||||
function areas:player_exists(name)
|
||||
return minetest.auth_table[name] ~= nil
|
||||
return minetest.get_auth_handler().get_auth(name) ~= nil
|
||||
end
|
||||
|
||||
-- Save the areas table to a file
|
||||
|
|
|
@ -0,0 +1 @@
|
|||
name = areas
|
Loading…
Reference in New Issue