Advertisement
Guest User

g

a guest
Mar 26th, 2019
75
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.80 KB | None | 0 0
  1. -- Coder: Julian B., @langeweile1533, Copyyy
  2. os.loadAPI("button")
  3. local m = peripheral.wrap("back")
  4. local mx, my = m.getSize()
  5. function getClick()
  6. local event, side, x, y = os.pullEvent()
  7. if event == "monitor_touch" then
  8. button.checkxy(x, y)
  9. end
  10. end
  11. function reactor1()
  12. button.toggleButton("AbwährSystem")
  13. if button.active("AbwährSystem") then
  14. -- print("now on")
  15. rs.setOutput("left", true)
  16. else
  17. -- print("now off")
  18. rs.setOutput("left", false)
  19. end
  20. button.save()
  21. addText()
  22. end
  23. function reactor2()
  24. button.toggleButton("Open...")
  25. if button.active("Open...") then
  26. -- print("now on")
  27. rs.setOutput("right", true)
  28. else
  29. -- print("now off")
  30. rs.setOutput("right", false)
  31. end
  32. button.save()
  33. addText()
  34. end
  35. function fillMainTable()
  36. m.clear()
  37. button.clearTable()
  38. button.setTable("Reactor 1", reactor1, "", 2, mx/2, 2, my-1)
  39. button.setTable("Reactor 2", reactor2, "", (mx/2)+2, mx-0.5, 2, my-1)
  40. --2,mx/2-1 -- mx/2+2, mx-0.5
  41. button.screen()
  42. end
  43. function addText()
  44. for i = 1,2 do
  45. m.setTextColor(colors.white)
  46. if i == 1 then
  47. local textr = "AbwährSystem"
  48. if button.active("AbwährSystem") then
  49. m.setBackgroundColor(colors.lime)
  50. else
  51. m.setBackgroundColor(colors.red)
  52. end
  53. m.setCursorPos(mx/4-#textr/2+1.75, my/2+1)
  54. m.write(textr)
  55. else
  56. local textr = "Open..."
  57. if button.active("Open...") then
  58. m.setBackgroundColor(colors.lime)
  59. else
  60. m.setBackgroundColor(colors.red)
  61. end
  62. m.setCursorPos(mx*0.75-#textr/2+1, my/2+1)
  63. m.write(textr)
  64. end
  65. end
  66. end
  67. fillMainTable()
  68. button.load()
  69. addText()
  70. while true do
  71. getClick()
  72. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement