Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- s = peripheral.wrap("bottom")
- local function doSonarSweep()
- s.setAttenuation(0)
- s.stop(0)
- s.start(0, 2438)
- sleep(0.2)
- s.start(1, 2532)
- sleep(0.2)
- s.setAttenuation(10)
- s.stop(0)
- s.start(2, 2614)
- sleep(0.4)
- s.stop(0)
- s.stop(1)
- s.stop(2)
- end
- local sonColors = {1024, 2048, 512, 8192, 32, 2, 16, 16384}
- local function clearScreen()
- term.setBackgroundColor(32768)
- term.clear()
- term.setCursorPos(1,1)
- term.setTextColor(1)
- term.setCursorPos(1, 1)
- term.write(" Selex ES - Sonar Attivo ")
- term.setCursorPos(25, 2)
- term.write("-O-")
- term.setCursorPos(50, 3)
- term.write("0")
- term.setCursorPos(50, 6)
- term.write(".5")
- term.setCursorPos(50, 9)
- term.write("1k")
- term.setCursorPos(50, 12)
- term.write("2k")
- term.setCursorPos(50, 15)
- term.write("4k")
- term.setCursorPos(50, 18)
- term.write("8k")
- term.setCursorPos(1, 3)
- term.write("0")
- term.setCursorPos(1, 6)
- term.write(".5")
- term.setCursorPos(1, 9)
- term.write("1k")
- term.setCursorPos(1, 12)
- term.write("2k")
- term.setCursorPos(1, 15)
- term.write("4k")
- term.setCursorPos(1, 18)
- term.write("8k")
- end
- local function drawLine(y, modifier)
- for i = 4, 48 do
- local ran = math.floor(math.random(1, 2))
- local m1 = math.floor(math.random(1, 3))
- local m2 = math.floor(math.random(1, 3))
- local m3 = math.floor(math.random(1, 2))
- if i > 30+m2 then
- ran = ran
- elseif i > 20-m1 then
- ran = ran + 1 + modifier
- -- elseif i < 20 then
- -- ran = ran
- end
- ran = ran + modifier
- if (ran+1) > 8 then
- ran = 9 - (math.floor(math.random(1,2)))
- end
- local colorBase = sonColors[ran]
- paintutils.drawPixel(i, y, colorBase)
- end
- end
- clearScreen()
- term.setCursorPos(21, 10)
- term.setBackgroundColor(colors.red)
- term.setTextColor(colors.white)
- term.write("AVVIA SONAR")
- event = os.pullEvent("mouse_click")
- clearScreen()
- doSonarSweep()
- while true do
- for i = 3, 21 do
- mod = 8 - i
- if mod < 0 then
- mod = 0
- end
- drawLine(i, mod)
- sleep(0.1)
- end
- doSonarSweep()
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement