Advertisement
chezpaul

Gustavo's Sonar

Oct 21st, 2015
164
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.30 KB | None | 0 0
  1. --- Decorative Sonar by Gustavo Wizard
  2. --- Monitor 2x2, btn API
  3.  
  4.  
  5. os.loadAPI("btn")
  6. m = peripheral.wrap("top")
  7. local commandBlock = peripheral.wrap("left")
  8. currentCommand = commandBlock.getCommand()
  9.  
  10. m.setTextScale(0.5)
  11.  
  12. m.setBackgroundColor(colors.black)
  13. m.clear()
  14.  
  15. m.setTextColor(colors.red)
  16. m.setCursorPos(8,2)
  17. m.write("TYPHOON TK-208 SONAR")
  18.  
  19. term.redirect(m)
  20.  
  21. m.setTextColor(colors.white)
  22. function fillTable()
  23. btn.setTable("SONAR ON", on, 6,16,20,22)
  24. btn.setTable("SONAR OFF", off,20,30,20,22)
  25. btn.screen()
  26. end
  27.  
  28. function getClick()
  29. event,side,x,y = os.pullEvent("monitor_touch")
  30. btn.checkxy(x,y)
  31. end
  32.  
  33.  
  34. function on()
  35. btn.toggleButton("SONAR ON")
  36. while true do
  37. local image = paintutils.loadImage("r.nfp")
  38. paintutils.drawImage(image,8,4)
  39. sleep(.3)
  40. local image = paintutils.loadImage("r2.nfp")
  41. paintutils.drawImage(image,8,4)
  42. sleep(.3)
  43. local image = paintutils.loadImage("r3.nfp")
  44. paintutils.drawImage(image,8,4)
  45. sleep(.3)
  46. local image = paintutils.loadImage("r4.nfp")
  47. paintutils.drawImage(image,8,4)
  48. commandBlock.setCommand("playsound wizard.sonar_low @a")
  49. commandBlock.runCommand()
  50. sleep(.3)
  51. end
  52. end
  53.  
  54. m.setBackgroundColor(colors.red)
  55. m.setTextColor(colors.white)
  56.  
  57. function off()
  58. btn.flash("SONAR OFF")
  59. end
  60.  
  61. fillTable()
  62.  
  63. while true do
  64.  
  65. getClick()
  66.  
  67. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement