Advertisement
Lukyrouge22

Pocket

Mar 9th, 2019
92
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.98 KB | None | 0 0
  1. os.loadAPI("touchpoint")
  2. local t = touchpoint.new()
  3. local modem = peripheral.wrap("back")
  4.  
  5. local outsidedoor = false
  6.  
  7. function queryStates()
  8. --outside door state
  9. modem.transmit(1, 2, "outsidedoor_state")
  10. local e, ms, sc, rc, msg, sd = os.pullEvent("modem_message")
  11. if msg == "true" then outsidedoor = true end
  12. end
  13.  
  14. function page1()
  15. -- t:add("<", page1(), 0, 0, 4, 4, colors.lightGray, colors.lightGray)
  16. t:add(">", nil, 22, 1, 26, 4, colors.red, colors.lime)
  17.  
  18. if outsidedoor then t:add("Outside Door", outsidedoor, 1, 6, 26, 8, colors.lime, colors.red)
  19. else t:add("Outside Door", outsidedoor, 1, 6, 26, 8, colors.red, colors.lime) end
  20. t:draw()
  21. end
  22.  
  23. function outsidedoor()
  24. modem.transmit(1, 2, "outsidedoor")
  25. if outsidedoor then outsidedoor = false
  26. else outsidedoor = true end
  27. page1()
  28. end
  29. queryStates()
  30. page1()
  31. while true do
  32. local event, p1 = t:handleEvents(os.pullEvent())
  33. if event == "button_click" then
  34. t:toogleButton(p1)
  35. t:run2(p1)
  36. end
  37. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement