lego11

Sonar Gorae

Oct 27th, 2021 (edited)
117
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. local function doSonarSweep()
  2.     rs.setOutput("back", true)
  3.     sleep(0.5)
  4.     rs.setOutput("back", false)
  5. end
  6.  
  7. local sonColors = {1024, 2048, 512, 8192, 32, 2, 16, 16384}
  8.  
  9. local function clearScreen()
  10.     term.setBackgroundColor(32768)
  11.     term.clear()
  12.     term.setCursorPos(1,1)
  13.     term.setTextColor(1)
  14.  
  15. term.setCursorPos(1, 1)
  16. term.write("       Sulyeog eumhyang danji «Arktika»")
  17. term.setCursorPos(25, 2)
  18. term.write("-O-")
  19.  
  20. term.setCursorPos(50, 3)
  21. term.write("0")
  22. term.setCursorPos(50, 6)
  23. term.write(".5")
  24. term.setCursorPos(50, 9)
  25. term.write("1k")
  26. term.setCursorPos(50, 12)
  27. term.write("2k")
  28. term.setCursorPos(50, 15)
  29. term.write("4k")
  30. term.setCursorPos(50, 18)
  31. term.write("8k")
  32.  
  33. term.setCursorPos(1, 3)
  34. term.write("0")
  35. term.setCursorPos(1, 6)
  36. term.write(".5")
  37. term.setCursorPos(1, 9)
  38. term.write("1k")
  39. term.setCursorPos(1, 12)
  40. term.write("2k")
  41. term.setCursorPos(1, 15)
  42. term.write("4k")
  43. term.setCursorPos(1, 18)
  44. term.write("8k")
  45. end
  46.  
  47. local function drawLine(y, modifier)
  48.     for i = 4, 48 do
  49.         local ran = math.floor(math.random(1, 2))
  50.         local m1 = math.floor(math.random(1, 3))
  51.         local m2 = math.floor(math.random(1, 3))            
  52.         local m3 = math.floor(math.random(1, 2))
  53.         if i > 30+m2 then
  54.             ran = ran
  55.         elseif i > 20-m1 then
  56.             ran = ran + 1 + modifier
  57. --        elseif i < 20 then
  58. --            ran = ran
  59.         end
  60.         ran = ran + modifier
  61.         if (ran+1) > 8 then
  62.             ran = 9 - (math.floor(math.random(1,2)))
  63.         end
  64.         local colorBase = sonColors[ran]
  65.         paintutils.drawPixel(i, y, colorBase)
  66.  
  67.    end
  68. end
  69.  
  70. clearScreen()
  71.  
  72.  
  73.  
  74. term.setCursorPos(21, 10)
  75. term.setBackgroundColor(colors.red)
  76. term.setTextColor(colors.white)
  77. term.write("SIYAG")
  78.  
  79.  
  80. event = os.pullEvent("mouse_click")
  81.  
  82. clearScreen()
  83. doSonarSweep()
  84.  
  85. while true do
  86.     for i = 3, 21 do
  87.         mod = 8 - i
  88.         if mod < 0 then
  89.           mod = 0
  90.         end
  91.         drawLine(i, mod)
  92.         sleep(0.1)
  93.     end
  94.     doSonarSweep()
  95. end
RAW Paste Data