optimize ar

This commit is contained in:
LordMZTE 2021-11-14 16:10:27 +01:00
parent cf7dbe96e6
commit fc29df0641
1 changed files with 18 additions and 8 deletions

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"
end
while true do
local text = {}
local cur_row = 0
table.insert(text, "Date: " .. os.date())
table.insert(text, "Players:")
local function draw_idx_string(string)
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
local pos = pl_detector.getPlayerPos(p)
if pos == nil then
table.insert(text, p .. " @ ?")
table.insert(draws, draw_idx_string(p .. " @ ?"))
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
cur_row = 0
ar.clear()
for i, l in ipairs(text) do
ar.drawString(l, 0, 10 * (i - 1), 0xffffff)
for _, l in ipairs(draws) do
l()
end
sleep(1)