SHOW:
|
|
- or go back to the newest paste.
| 1 | monitor = peripheral.wrap("top")
| |
| 2 | w,h = monitor.getSize() | |
| 3 | ||
| 4 | function attButton(state) | |
| 5 | monitor.setCursorPos(2,4) | |
| 6 | if state then | |
| 7 | monitor.setBackgroundColor(colors.green) | |
| 8 | else | |
| 9 | monitor.setBackgroundColor(colors.black) | |
| 10 | end | |
| 11 | monitor.write("ON")
| |
| 12 | monitor.setCursorPos(6,4) | |
| 13 | if state then | |
| 14 | monitor.setBackgroundColor(colors.black) | |
| 15 | else | |
| 16 | monitor.setBackgroundColor(colors.red) | |
| 17 | end | |
| 18 | monitor.write("OFF")
| |
| 19 | end | |
| 20 | ||
| 21 | function ini() | |
| 22 | monitor.setBackgroundColor(colors.gray) | |
| 23 | monitor.clear() | |
| 24 | monitor.setCursorPos(3,2) | |
| 25 | monitor.setTextScale(1.5) | |
| 26 | monitor.write("Botรขo")
| |
| 27 | attButton(false) | |
| 28 | end | |
| 29 | ini() | |
| 30 | ||
| 31 | while true do | |
| 32 | event, side, xPos, yPos = os.pullEvent("monitor_touch")
| |
| 33 | --monitor.clear() | |
| 34 | --info = "x:"..xPos..", y:"..yPos | |
| 35 | --monitor.setCursorPos(w/2-#info/2,h/2) | |
| 36 | --monitor.write(info) | |
| 37 | if yPos == 4 then | |
| 38 | if xPos >= 2 and xPos <= 3 then | |
| 39 | attButton(true) | |
| 40 | redstone.setOutput("right",true)
| |
| 41 | end | |
| 42 | if xPos >= 6 and xPos <= 8 then | |
| 43 | attButton(false) | |
| 44 | redstone.setOutput("right",false)
| |
| 45 | end | |
| 46 | end | |
| 47 | end |