-- 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() local pos = vector.round(player:getpos()) local areaStrings = {} local saw_old01 = false local saw_old02 = false for id, area in pairs (areas:getAreasAtPos (pos)) do -- RJK: List at most one Legacy Protector entry at a time or the dis- -- play may be flooded with them. -- Update: Implement the same fix for entries with names that start -- with "Converted from Protectors". -- RJK: Additionally, limit the height of the display to a reasonable -- number of lines regardless. local show_it01 = true local show_it02 = true if area.name == areas.legacy_label01 then if saw_old01 then show_it01 = false else saw_old01 = true end end if ocutil.starts_with (area.name, areas.legacy_label02) then if saw_old02 then show_it02 = false else saw_old02 = true end end if show_it01 and show_it02 then table.insert (areaStrings, ("%s [%u] (%s%s)") :format (area.name, id, area.owner, area.open and ":open" or "")) if #areaStrings >= 6 then break end end 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".. 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)