2013-09-26 16:30:36 +02:00
|
|
|
-- 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()
|
2013-11-19 03:04:14 +01:00
|
|
|
local pos = vector.round(player:getpos())
|
2014-01-16 02:10:24 +01:00
|
|
|
local a = areas:getAreasAtPos(pos)
|
|
|
|
local areaString = ""
|
|
|
|
local first = true
|
|
|
|
for id, area in pairs(areas:getAreasAtPos(pos)) do
|
|
|
|
if not first then
|
|
|
|
areaString = areaString..", "
|
|
|
|
else
|
|
|
|
first = false
|
|
|
|
end
|
2014-02-07 19:05:23 +01:00
|
|
|
local ownertxt = area.owner
|
|
|
|
if area.open then
|
|
|
|
ownertxt = ownertxt.."/open"
|
|
|
|
end
|
2014-02-07 19:18:03 +01:00
|
|
|
areaString = areaString..area.name.." ("..id.."/"..ownertxt..")"
|
2014-01-16 02:10:24 +01:00
|
|
|
end
|
2013-11-19 03:04:14 +01:00
|
|
|
if not areas.hud[name] then
|
|
|
|
areas.hud[name] = {}
|
2014-01-16 02:10:24 +01:00
|
|
|
areas.hud[name].areasId = player:hud_add({
|
2013-11-19 03:04:14 +01:00
|
|
|
hud_elem_type = "text",
|
2014-01-16 02:10:24 +01:00
|
|
|
name = "Areas",
|
2013-11-19 03:04:14 +01:00
|
|
|
number = 0xFFFFFF,
|
|
|
|
position = {x=0, y=1},
|
2013-11-19 03:08:22 +01:00
|
|
|
offset = {x=5, y=-60},
|
2013-11-19 03:04:14 +01:00
|
|
|
direction = 0,
|
2014-01-16 02:10:24 +01:00
|
|
|
text = "Areas: "..areaString,
|
2013-11-19 03:08:22 +01:00
|
|
|
scale = {x=200, y=60},
|
2013-11-19 03:04:14 +01:00
|
|
|
alignment = {x=1, y=1},
|
|
|
|
})
|
2014-01-16 02:10:24 +01:00
|
|
|
areas.hud[name].oldAreas = areaString
|
2013-11-19 03:04:14 +01:00
|
|
|
return
|
2014-01-16 02:10:24 +01:00
|
|
|
elseif areas.hud[name].oldAreas ~= areaString then
|
|
|
|
player:hud_change(areas.hud[name].areasId, "text",
|
|
|
|
"Areas: "..areaString)
|
|
|
|
areas.hud[name].oldAreas = areaString
|
2013-09-26 16:30:36 +02:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end)
|
|
|
|
|
|
|
|
minetest.register_on_leaveplayer(function(player)
|
|
|
|
areas.hud[player:get_player_name()] = nil
|
|
|
|
end)
|
|
|
|
|