Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- monitor = peripheral.wrap("top")
- w,h = monitor.getSize()
- function attButton(state)
- monitor.setCursorPos(2,4)
- if state then
- monitor.setBackgroundColor(colors.green)
- else
- monitor.setBackgroundColor(colors.black)
- end
- monitor.write("ON")
- monitor.setCursorPos(6,4)
- if state then
- monitor.setBackgroundColor(colors.black)
- else
- monitor.setBackgroundColor(colors.red)
- end
- monitor.write("OFF")
- end
- function ini()
- monitor.setBackgroundColor(colors.gray)
- monitor.clear()
- monitor.setCursorPos(3,2)
- monitor.setTextScale(1.5)
- monitor.write("Botâo")
- attButton(false)
- end
- ini()
- while true do
- event, side, xPos, yPos = os.pullEvent("monitor_touch")
- --monitor.clear()
- --info = "x:"..xPos..", y:"..yPos
- --monitor.setCursorPos(w/2-#info/2,h/2)
- --monitor.write(info)
- if yPos == 4 then
- if xPos >= 2 and xPos <= 3 then
- attButton(true)
- redstone.setOutput("right",true)
- end
- if xPos >= 6 and xPos <= 8 then
- attButton(false)
- redstone.setOutput("right",false)
- end
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment