optimize ar

This commit is contained in:
LordMZTE 2021-11-14 16:10:27 +01:00
parent cf7dbe96e6
commit fc29df0641

View file

@ -5,24 +5,34 @@ if ar == nil or pl_detector == nil then
error "couldnt find all peripherals. need ar controller and player detector" error "couldnt find all peripherals. need ar controller and player detector"
end end
while true do local cur_row = 0
local text = {}
table.insert(text, "Date: " .. os.date()) local function draw_idx_string(string)
table.insert(text, "Players:") return function()
ar.drawString(string, 0, 10 * cur_row, 0xffffff)
cur_row = cur_row + 1
end
end
while true do
local draws = {}
table.insert(draws, draw_idx_string("Date: " .. os.date()))
table.insert(draws, draw_idx_string("Players:"))
for _, p in pairs(pl_detector.getOnlinePlayers()) do for _, p in pairs(pl_detector.getOnlinePlayers()) do
local pos = pl_detector.getPlayerPos(p) local pos = pl_detector.getPlayerPos(p)
if pos == nil then if pos == nil then
table.insert(text, p .. " @ ?") table.insert(draws, draw_idx_string(p .. " @ ?"))
else else
table.insert(text, p .. " @ X: " .. pos.x .. " Y: " .. pos.y .. " Z: " .. pos.z) table.insert(draws, draw_idx_string(p .. " @ X: " .. pos.x .. " Y: " .. pos.y .. " Z: " .. pos.z))
end end
end end
cur_row = 0
ar.clear() ar.clear()
for i, l in ipairs(text) do for _, l in ipairs(draws) do
ar.drawString(l, 0, 10 * (i - 1), 0xffffff) l()
end end
sleep(1) sleep(1)