Guest User

sonar

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