2016-04-01 20:02:19 -04:00
|
|
|
-- This is inspired by the landrush mod by Bremaweb
|
|
|
|
|
|
|
|
areas.hud = {}
|
2019-04-02 18:04:55 -04:00
|
|
|
areas.hud.refresh = 0
|
2016-04-01 20:02:19 -04:00
|
|
|
|
|
|
|
minetest.register_globalstep(function(dtime)
|
2019-04-02 18:04:55 -04:00
|
|
|
|
|
|
|
areas.hud.refresh = areas.hud.refresh + dtime
|
|
|
|
if areas.hud.refresh > areas.config["tick"] then
|
|
|
|
areas.hud.refresh = 0
|
|
|
|
else
|
|
|
|
return
|
|
|
|
end
|
|
|
|
|
2016-04-01 20:02:19 -04:00
|
|
|
for _, player in pairs(minetest.get_connected_players()) do
|
|
|
|
local name = player:get_player_name()
|
update castles, areas, areas_protector, bakedclay, signs_lib,
bees, blox, bobblocks, coloredwood, homedecor, technic,
currency, digilines, digistguff, facade, farming_redo,
framedglass, gloopblocks, ilights, led_marquee, maptools,
mesecons, moreblocks, moreores, mymillwork, plasticbox,
replacer, ropes, street_signs, solidcolor, stained_glass,
teleport_request, unified_inventory, unifieddyes, worldedit,
add basic_signs, notify_hud_provider
2019-09-11 13:58:21 -04:00
|
|
|
local pos = vector.round(player:get_pos())
|
2019-04-02 18:04:55 -04:00
|
|
|
pos = vector.apply(pos, function(p)
|
|
|
|
return math.max(math.min(p, 2147483), -2147483)
|
|
|
|
end)
|
2016-04-01 20:02:19 -04:00
|
|
|
local areaStrings = {}
|
Huge update - lots of mods:
areas, biome_lib, blox, bobblocks, boost_cart, homedecor, mobs,
coloredwood, ilights, inbox, item_tweaks, moreblocks, moreores,
pipeworks, plasticbox, signs_lib, stainedglass, roads, unifieddyes,
vines, worldedit, xban2, maybe some others I didn't think about ;-)
2017-01-31 19:39:31 -05:00
|
|
|
|
2016-04-01 20:02:19 -04:00
|
|
|
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
|
Huge update - lots of mods:
areas, biome_lib, blox, bobblocks, boost_cart, homedecor, mobs,
coloredwood, ilights, inbox, item_tweaks, moreblocks, moreores,
pipeworks, plasticbox, signs_lib, stainedglass, roads, unifieddyes,
vines, worldedit, xban2, maybe some others I didn't think about ;-)
2017-01-31 19:39:31 -05:00
|
|
|
|
|
|
|
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
|
|
|
|
|
2016-04-01 20:02:19 -04:00
|
|
|
local areaString = "Areas:"
|
|
|
|
if #areaStrings > 0 then
|
|
|
|
areaString = areaString.."\n"..
|
|
|
|
table.concat(areaStrings, "\n")
|
|
|
|
end
|
|
|
|
local hud = areas.hud[name]
|
|
|
|
if not hud then
|
|
|
|
hud = {}
|
|
|
|
areas.hud[name] = hud
|
|
|
|
hud.areasId = player:hud_add({
|
|
|
|
hud_elem_type = "text",
|
|
|
|
name = "Areas",
|
|
|
|
number = 0xFFFFFF,
|
|
|
|
position = {x=0, y=1},
|
|
|
|
offset = {x=8, y=-8},
|
|
|
|
text = areaString,
|
|
|
|
scale = {x=200, y=60},
|
|
|
|
alignment = {x=1, y=-1},
|
|
|
|
})
|
|
|
|
hud.oldAreas = areaString
|
|
|
|
return
|
|
|
|
elseif hud.oldAreas ~= areaString then
|
|
|
|
player:hud_change(hud.areasId, "text", areaString)
|
|
|
|
hud.oldAreas = areaString
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end)
|
|
|
|
|
|
|
|
minetest.register_on_leaveplayer(function(player)
|
|
|
|
areas.hud[player:get_player_name()] = nil
|
|
|
|
end)
|
|
|
|
|