Advertisement
Guest User

Untitled

a guest
Oct 31st, 2014
128
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.93 KB | None | 0 0
  1. on=true
  2. local mon=peripheral.wrap("monitor_0")
  3. local width, height=mon.getSize()
  4. print(width.." "..height)
  5. print 'setting "on" to true'
  6. mon.setCursorPos(1,1)
  7. mon.write("Current state: OFF ")
  8. mon.setCursorPos(5,5)
  9. mon.write("Click to turn ON power ")
  10. function draw(x,y)
  11. --what will happen after click
  12. if (on==true) then
  13. on=false
  14. print 'setting "on" to false'
  15. elseif (on==false) then
  16. on=true
  17. print 'setting "on" to true'
  18. end
  19. if (on==true) then
  20. mon.setCursorPos(1,1)
  21. mon.write("Current state: OFF ")
  22. mon.setCursorPos(5,5)
  23. mon.write("click to turn ON power ")
  24. rs.setOutput("left",false)
  25. elseif (on==false) then
  26. mon.setCursorPos(1,1)
  27. mon.write("Current state: ON ")
  28. mon.setCursorPos(5,5)
  29. mon.write("click to turn OFF power ")
  30. rs.setOutput("left",true)
  31. end
  32. end
  33.  
  34. while true do
  35. local event, side, x, y=os.pullEvent("monitor_touch")
  36. draw(x,y)
  37. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement