Shockwve

Untitled

Jun 25th, 2016
50
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.34 KB | None | 0 0
  1. os.loadAPI("button")
  2. m = peripheral.wrap("right")
  3. m.clear()
  4.  
  5. color1 = 1
  6. color2 = 1
  7. color3 = 1
  8.  
  9. function fillTable()
  10. button.setTable("Color 1", changeColor1, 2,12,2,11)
  11. button.setTable("Color 2", changeColor2, 15,25,2,11)
  12. button.setTable("Color 3", changeColor3, 28,38,2,11)
  13. button.setTable("Set Colors", setColors, 4,36, 14, 17)
  14. button.screen()
  15. end
  16.  
  17. function getClick()
  18. event, side, x, y = os.pullEvent("monitor_touch")
  19. button.checkxy(x,y)
  20. end
  21.  
  22. function changeColor(colorNum)
  23. colorNum = colorNum * 2
  24. if colorNum > 32786 then
  25. colorNum = 1
  26. end
  27. return colorNum
  28. end
  29.  
  30. function changeColor1()
  31. color1 = changeColor(color1)
  32. button.setColor("Color 1", color1)
  33. end
  34.  
  35. function changeColor2()
  36. color2 = changeColor(color2)
  37. button.setColor("Color 2", color2)
  38. end
  39.  
  40. function changeColor3()
  41. color3 = changeColor(color3)
  42. button.setColor("Color 3", color3)
  43. end
  44.  
  45. function setColors()
  46. chest = peripheral.wrap("top")
  47. if chest == nil then
  48. print("No Chest")
  49. else
  50. if peripheral.getType("top") == "ender_chest" then
  51. chest.setColors(color1, color2, color3)
  52. else
  53. chest.setColors(color3, color2, color1)
  54. end
  55. end
  56. end
  57.  
  58. fillTable()
  59. button.setColor("Color 1", color1)
  60. button.setColor("Color 2", color2)
  61. button.setColor("Color 3", color3)
  62. while true do
  63. getClick()
  64. end
Add Comment
Please, Sign In to add comment