Advertisement
chezpaul

onoff

Nov 27th, 2015
199
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.87 KB | None | 0 0
  1. --# load the Touchpoint API
  2. loadup = function()
  3. shell.run("pastebin", "get", "pFHeia96", "touchpoint")
  4. os.loadAPI("touchpoint")
  5. print("Touchpoint API Loaded")
  6. sleep(1)
  7. term.clear()
  8. term.setCursorPos(1,1)
  9. end
  10.  
  11. loadup()
  12.  
  13. function rson()
  14. rs.setOutput("top", true)
  15. end
  16. function rsoff()
  17. rs.setOutput("top", false)
  18. end
  19.  
  20. local t = touchpoint.new("front")
  21.  
  22. t:add("Lights", nil, 1, 1, 7, 1, colors.black, colors.black)
  23. t:add("OFF", nil, 2, 2, 6, 4, colors.red, colors.lime)
  24.  
  25. t:draw()
  26.  
  27. while true do
  28.  
  29. local event, p1 = t:handleEvents(os.pullEvent())
  30. if event == "button_click" then
  31. t:toggleButton(p1)
  32. if p1 == "OFF" then
  33. t:rename("OFF", "ON")
  34. rson()
  35. elseif p1 == "ON" then
  36. t:rename("ON", "OFF")
  37. rsoff()
  38. end
  39.  
  40. end
  41. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement