Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- os.loadAPI("button")
- local m = peripheral.wrap("back")
- local mx, my = m.getSize()
- function getClick()
- local event, side, x, y = os.pullEvent()
- if event == "monitor_touch" then
- button.checkxy(x, y)
- end
- end
- function reactor1()
- button.toggleButton("Test 1")
- if button.active("Test 1") then
- -- print("now on")
- rs.setOutput("left", true)
- else
- -- print("now off")
- rs.setOutput("left", false)
- end
- button.save()
- addText()
- end
- function reactor2()
- button.toggleButton("Test 2")
- if button.active("Test 2") then
- -- print("now on")
- rs.setOutput("right", true)
- else
- -- print("now off")
- rs.setOutput("right", false)
- end
- button.save()
- addText()
- end
- function fillMainTable()
- m.clear()
- button.clearTable()
- button.setTable("Test 1", test1, "", 2, mx/2, 2, my-1)
- button.setTable("Test 2", test2, "", (mx/2)+2, mx-0.5, 2, my-1)
- --2,mx/2-1 -- mx/2+2, mx-0.5
- button.screen()
- end
- function addText()
- for i = 1,2 do
- m.setTextColor(colors.white)
- if i == 1 then
- if button.active("Test 1") then
- m.setBackgroundColor(colors.lime)
- else
- m.setBackgroundColor(colors.red)
- end
- m.setCursorPos(mx/4-#textr/2+1.75, my/2+1)
- m.write(textr)
- else
- if button.active("Test 2") then
- m.setBackgroundColor(colors.lime)
- else
- m.setBackgroundColor(colors.red)
- end
- m.setCursorPos(mx*0.75-#textr/2+1, my/2+1)
- m.write(textr)
- end
- end
- end
- fillMainTable()
- button.load()
- addText()
- while true do
- getClick()
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement