xavierlebel

MENU2

Mar 4th, 2014
119
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. --# load the Touchpoint API
  2. os.loadAPI("touchpoint")
  3. p = peripheral.wrap("back")
  4.  
  5. --# FUNCTIONS
  6.  
  7. function pulse()
  8. redstone.setOutput("back", true)
  9. sleep(0,5)
  10. redstone.setOutput("back", false)
  11. end
  12.  
  13. function peat()
  14. p.setFreq(151)
  15. pulse()
  16. end
  17.  
  18. function pumpkin()
  19. p.setFreq(152)
  20. pulse()
  21. end
  22.  
  23. function melon()
  24. p.setFreq(153)
  25. pulse()
  26. end
  27.  
  28. --# intialize a new button set on the top monitor
  29. local t = touchpoint.new("top")
  30.  
  31. --# add buttons
  32. t:add("PEAT", nil, 2, 2, 16, 4, colors.red, colors.lime)
  33. --t:add("PUMPKIN", nil, 2, 2, 28, 11, colors.lime, colors.red)
  34. --t:add("MELON", nil, 2, 2, 28, 11, colors.lime, colors.red)
  35.  
  36. --# draw the buttons
  37. t:draw()
  38.  
  39. while true do
  40. local event, p1 = t:handleEvents(os.pullEvent())
  41. if event == "button_click" then
  42. t:toggleButton(p1)
  43.  
  44. if p1 == "PEAT" then
  45. peat()
  46. --elseif p1 == "PUMPKIN" then
  47. -- pumpkin()
  48. else
  49. melon()
  50. end
  51. end
  52. end
Advertisement
Add Comment
Please, Sign In to add comment