Advertisement
Cognomech

RadioRave

Jul 31st, 2015
297
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. -- RadioRave v1.2 by Hyper_Space
  2. -- Credit to Vic Fieger for the Karmatic Arcade font, which has been adapted for ComputerCraft and used in the HyperPrint API.
  3. -- Got a suggestion? Awesome! Please send it over to me at or contact Hyper_Space on the ZephTech Minecraft Server.
  4. -- Changelog
  5. -- v1.2 - Checks added. Terminal imagery has now been designed, with a help message on the right. Auto-updater
  6. -- added.
  7. -- v1.1 - Vastly improved monitor graphics, including a fancy top-monitor animation.
  8. -- v1.0 - Original program.
  9. -- To-Do
  10. -- -Colour themes
  11.  
  12. if fs.exists("HyperPrint")== false then
  13.  term.clear()
  14.  term.setCursorPos(1,1)
  15.  print("RadioRave requires HyperPrint (http://pastebin.com/bKb3SEe8) to function as intended")
  16.  return
  17. end
  18. os.loadAPI("HyperPrint")
  19. montop = peripheral.wrap("top")
  20. monleft = peripheral.wrap("left")
  21. monright = peripheral.wrap("right")
  22.  
  23. if (peripheral.getType("top") ~= "monitor")
  24. or (peripheral.getType("left") ~= "monitor")
  25. or (peripheral.getType("right") ~= "monitor") then
  26.  term.clear()
  27.  term.setCursorPos(1,1)
  28.  print("RadioRave requires advanced monitors attached at the top, left and right to function as intended.")
  29.  return
  30. end
  31.  
  32. montop.setTextScale(0.5)
  33. monleft.setTextScale(0.5)
  34. monright.setTextScale(0.5)
  35. phase = 0
  36. vol = 0
  37. termxmax,termymax = term.getSize()
  38. title = "RadioRave"
  39.  
  40. term.clear()
  41. for i=1,30 do
  42.  paintutils.drawLine(i,1,i,termymax,colours.blue)
  43. end
  44. for i=2,29 do
  45.  paintutils.drawLine(i,2,i,termymax-1,colours.cyan)
  46. end
  47. HyperPrint.printNote(2,2)
  48. HyperPrint.printR(10,6)
  49. for i=32,termxmax-1 do
  50.  paintutils.drawLine(i,1,i,3,colours.blue)
  51. end
  52. for i=33,termxmax-2 do
  53.  paintutils.drawLine(i,2,i,2,colours.cyan)
  54. end
  55. term.setCursorPos(37,2)
  56. term.setTextColour(colours.white)
  57. print(title)
  58. term.setBackgroundColour(colours.black)
  59. term.setCursorPos(32,4)
  60. print("v1.2 by Hyper_Space")
  61. term.setCursorPos(32,6)
  62. print("To start using this")
  63. term.setCursorPos(32,7)
  64. print("program, simply")
  65. term.setCursorPos(32,8)
  66. print("place an OpenBlocks")
  67. term.setCursorPos(32,9)
  68. print("radio under the")
  69. term.setCursorPos(32,10)
  70. print("computer and press")
  71. term.setCursorPos(32,11)
  72. print("the arrows to")
  73. term.setCursorPos(32,12)
  74. print("adjust the volume.")
  75. os.unloadAPI("HyperPrint")
  76.  
  77. function touchscreens()
  78.  while true do
  79.   os.loadAPI("HyperPrint")
  80.   term.redirect(monleft)
  81.    for i=1,15 do
  82.     paintutils.drawLine(i,1,i,10,colours.blue)
  83.    end
  84.    HyperPrint.printLessThan(3,0)
  85.   term.redirect(monright)
  86.    for i=1,15 do
  87.     paintutils.drawLine(i,1,i,10,colours.blue)
  88.    end
  89.    HyperPrint.printGreaterThan(2,0)
  90.   rs.setAnalogOutput("bottom",vol)
  91.   event,side,x,y = os.pullEvent()
  92.   if (side == "left") and (event == "monitor_touch") then
  93.    term.redirect(monleft)
  94.     for i=1,15 do
  95.      paintutils.drawLine(i,1,i,10,colours.cyan)
  96.     end
  97.     HyperPrint.printLessThan(3,0)  
  98.     if vol ~= 0 then
  99.      vol = vol-1
  100.     end
  101.    term.redirect(term.native())
  102.    sleep(0.15)
  103.   elseif (side == "right") and (event == "monitor_touch") then
  104.    term.redirect(monright)
  105.     for i=1,15 do
  106.      paintutils.drawLine(i,1,i,10,colours.cyan)
  107.     end
  108.     HyperPrint.printGreaterThan(2,0)
  109.     if vol ~= 15 then
  110.      vol=vol+1
  111.     end
  112.    term.redirect(term.native())
  113.    sleep(0.15)
  114.   end
  115.  end
  116.  os.unloadAPI("HyperPrint")
  117. end
  118.  
  119. function top()
  120.  while true do
  121.   os.loadAPI("HyperPrint")
  122.   term.redirect(montop)
  123.    if phase == 0 then
  124.     for i=1,15 do
  125.      paintutils.drawLine(i,1,i,10,colours.blue)
  126.     end
  127.     paintutils.drawPixel(6,2,colours.black)
  128.     paintutils.drawPixel(6,9,colours.black)
  129.     paintutils.drawLine(5,3,6,3,colours.black)
  130.     paintutils.drawLine(5,8,6,8,colours.black)
  131.     paintutils.drawLine(4,4,6,4,colours.black)
  132.     paintutils.drawLine(4,7,6,7,colours.black)
  133.     for i=5,6 do
  134.      paintutils.drawLine(3,i,6,i,colours.black)
  135.     end
  136.     paintutils.drawLine(10,4,10,7,colours.black)
  137.     paintutils.drawLine(13,2,13,9,colours.black)
  138.    phase = 1
  139.    elseif phase == 1 then
  140.     for i=1,15 do
  141.      paintutils.drawLine(i,1,i,10,colours.cyan)
  142.     end
  143.     HyperPrint.printSpeaker(1,0,colours.black)
  144.     paintutils.drawLine(8,5,8,6,colours.black)
  145.     paintutils.drawLine(11,3,11,8,colours.black)
  146.     paintutils.drawLine(14,2,14,9,colours.black)
  147.     phase=2
  148.    elseif phase == 2 then
  149.     for i=1,15 do
  150.      paintutils.drawLine(i,1,i,10,colours.lightBlue)
  151.     end
  152.     HyperPrint.printSpeaker(1,0,colours.black)
  153.     paintutils.drawLine(9,4,9,7,colours.black)
  154.     paintutils.drawLine(12,3,12,8,colours.black)
  155.     paintutils.drawLine(15,1,15,10,colours.black)
  156.     phase=0
  157.    end
  158.   term.redirect(term.native())
  159.   montop.setCursorPos(3,5)
  160.   montop.write("Vol:")
  161.   montop.setCursorPos(3,6)
  162.   montop.write(tostring(vol))
  163.   sleep(0.25)
  164.  end
  165.  os.unloadAPI("HyperPrint")
  166. end
  167.  
  168. parallel.waitForAll(top,touchscreens)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement