Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- on=true
- local mon=peripheral.wrap("monitor_0")
- local width, height=mon.getSize()
- print(width.." "..height)
- print 'setting "on" to true'
- mon.setCursorPos(1,1)
- mon.write("Current state: OFF ")
- mon.setCursorPos(5,5)
- mon.write("Click to turn ON power ")
- function draw(x,y)
- --what will happen after click
- if (on==true) then
- on=false
- print 'setting "on" to false'
- elseif (on==false) then
- on=true
- print 'setting "on" to true'
- end
- if (on==true) then
- mon.setCursorPos(1,1)
- mon.write("Current state: OFF ")
- mon.setCursorPos(5,5)
- mon.write("click to turn ON power ")
- rs.setOutput("left",false)
- elseif (on==false) then
- mon.setCursorPos(1,1)
- mon.write("Current state: ON ")
- mon.setCursorPos(5,5)
- mon.write("click to turn OFF power ")
- rs.setOutput("left",true)
- end
- end
- while true do
- local event, side, x, y=os.pullEvent("monitor_touch")
- draw(x,y)
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement