Update HUD

master
Maksym H 2022-09-01 12:28:05 +03:00
parent 5d6efc741a
commit cf71c5d87d
1 changed files with 12 additions and 7 deletions

19
hud.lua
View File

@ -5,14 +5,13 @@ local S = areas.S
areas.hud = {} areas.hud = {}
local vround = vector.round local vround = vector.round
local tconcat = table.concat local tconcat, tinsert = table.concat, table.insert
local function update_hud(player, name, pos) local function update_hud(player, name, pos)
local areaStrings = { local areaStrings = {}
S("Areas:") local getAreasAtPos = areas:getAreasAtPos(pos)
}
for id, area in pairs(areas:getAreasAtPos(pos)) do for id, area in pairs(getAreasAtPos) do
areaStrings[#areaStrings + 1] = ("%s [%u] (%s)%s%s") areaStrings[#areaStrings + 1] = ("%s [%u] (%s)%s%s")
:format(area.name, id, area.owner, :format(area.name, id, area.owner,
area.open and (" [" .. S("Open") .. "]") or "", area.open and (" [" .. S("Open") .. "]") or "",
@ -27,9 +26,15 @@ local function update_hud(player, name, pos)
areaStrings[#areaStrings + 1] = str areaStrings[#areaStrings + 1] = str
end end
-- "Areas:" text has index 1 if areas.invite_code then
local areaString = #areaStrings > 1 and tconcat(areaStrings, "\n") or "" areaStrings[#areaStrings + 1] = areas.invite_code
end
if next(getAreasAtPos) then
tinsert(areaStrings, 1, S("Areas:"))
end
local areaString = tconcat(areaStrings, "\n")
local hud = areas.hud[name] local hud = areas.hud[name]
if not hud then if not hud then
hud = {} hud = {}