Fixed missing echos in radar LUA scan scripts for OC & CC

This commit is contained in:
Unknown 2018-02-03 22:08:23 +01:00
parent a51b884f44
commit 0e63bb6867
2 changed files with 18 additions and 25 deletions

View file

@ -36,7 +36,7 @@ local radius = tonumber(argv[1])
local scale = 50
local w, h = term.getSize()
local radarX, radarY, radarZ = radar.position()
local _, _, _, _, radarX, radarY, radarZ = radar.position()
term.clear()
@ -55,7 +55,7 @@ function textOut(x, y, text, fg, bg)
term.write(text)
local _, yt = term.getCursorPos()
term.setCursorPos(1, yt + 1)
end
end
function translateXZ(oldX, oldZ)
local x = radarX - oldX
@ -84,18 +84,12 @@ function scanAndDraw()
local energy, energyMax = radar.energy()
if energy == nil then energy = 0 end
if energyMax == nil or energyMax == 0 then energyMax = 1 end
local energyRequired = radar.getEnergyRequired(radius)
if energyRequired == nil then energyRequired = 0 end
if (energyRequired <= 0 or energy < energyRequired) then
local hh = math.floor(h / 2)
local hw = math.floor(w / 2)
paintutils.drawLine(hw - 5, hh - 1, hw + 5, hh - 1, colors.red)
paintutils.drawLine(hw - 5, hh, hw + 5, hh, colors.red)
textOut(hw - 4, hh,"LOW POWER", colors.white, colors.red)
paintutils.drawLine(hw - 5, hh + 1, hw + 5, hh + 1, colors.red)
textOut((w / 2) - 7, 1, " /!\\ LOW POWER ", colors.white, colors.red)
os.sleep(1)
return 0
@ -103,23 +97,25 @@ function scanAndDraw()
radar.radius(radius)
radar.start()
local scanDuration = radar.getScanDuration(radius)
textOut((w / 2) - 7, 1, " ping sent ", colors.gray, colors.black)
os.sleep(scanDuration)
redraw()
drawContact(radarX, radarY, radarZ, "RAD", colors.yellow)
local numResults = radar.getResultsCount()
if (numResults ~= 0) then
for i = 0, numResults-1 do
local success, _, name, cx, cy, cz = radar.getResult(i)
if success then
drawContact(cx, cy, cz, name, colors.red)
end
end
end
drawContact(radarX, radarY, radarZ, "RAD", colors.yellow)
os.sleep(scanDuration)
end
function redraw()
@ -127,9 +123,7 @@ function redraw()
paintutils.drawLine(1, 1, w, 1, colors.black)
textOut((w / 2) - 8, 1, "= Q-Radar v0.3 =", colors.white, colors.black)
textOut(w - 3, 1, "[X]", colors.white, colors.red)
textOut((w / 2) - 7, 1, "= Q-Radar v0.4 =", colors.white, colors.black)
paintutils.drawLine(1, h, w, h, colors.black)
local energy, _ = radar.energy()
@ -140,6 +134,7 @@ end
local continue = true
while continue do
scanAndDraw()
os.sleep(0)
end
term.clear()

View file

@ -38,7 +38,7 @@ local radius = tonumber(argv[1])
local scale = 50
local w, h = component.gpu.getResolution()
local radarX, radarY, radarZ = radar.position()
local _, _, _, _, radarX, radarY, radarZ = radar.position()
term.clear()
@ -97,11 +97,7 @@ function scanAndDraw()
if energyRequired == nil then energyRequired = 0 end
if (energyRequired <= 0 or energy < energyRequired) then
local hh = math.floor(h / 2)
local hw = math.floor(w / 2)
drawBox(hw - 5, hh - 1, 11, 3, 0xFF0000)
textOut(hw - 4, hh, "LOW POWER", 0xFFFFFF, 0xFF0000)
textOut((w / 2) - 7, 1, " /!\\ LOW POWER ", 0xFFFFFF, 0xFF0000)
os.sleep(1)
return 0
@ -110,10 +106,13 @@ function scanAndDraw()
radar.radius(radius)
radar.start()
local scanDuration = radar.getScanDuration(radius)
textOut(w - 3, 1, " ping sent ", 0x808080, 0x000000)
os.sleep(scanDuration)
redraw()
drawContact(radarX, radarY, radarZ, "RAD", 0xFFFF00)
local numResults = radar.getResultsCount()
if (numResults ~= 0) then
@ -125,7 +124,7 @@ function scanAndDraw()
end
end
drawContact(radarX, radarY, radarZ, "RAD", 0xFFFF00)
os.sleep(scanDuration)
end
function redraw()
@ -136,9 +135,7 @@ function redraw()
drawBox(1, h, w, 1, 0x000000)
drawBox(w, 1, w, h, 0x000000)
textOut((w / 2) - 8, 1, "= Q-Radar v0.3 =", 0xFFFFFF, 0x000000)
textOut(w - 3, 1, "[X]", 0xFFFFFF, 0xFF0000)
textOut((w / 2) - 8, 1, "= Q-Radar v0.4 =", 0xFFFFFF, 0x000000)
local energy, _ = radar.energy()
if energy == nil then energy = 0 end
@ -148,6 +145,7 @@ end
local continue = true
while component.isAvailable("warpdriveRadar") and continue do
scanAndDraw()
os.sleep(0)
end
term.clear()