Advertisement
Guest User

doorkey

a guest
Nov 24th, 2017
63
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.84 KB | None | 0 0
  1. os.loadAPI("touchpoint")
  2. local t = touchpoint.new("back")
  3.  
  4. function doorOpen()
  5.     rs.setBundledOutput("right", colors.red)
  6.     sleep(0.15)
  7.     rs.setBundledOutput("right", 0)
  8.     door = "open"
  9. end
  10.  
  11. function doorClose()
  12.     rs.setBundledOutput("right", colors.green)
  13.     sleep(0.15)
  14.     rs.setBundledOutput("right", colors.combine(colors.green, colors.red))
  15.     door = "closed"
  16. end
  17. doorClose()
  18. doorOpen()
  19. t:add ("open", nil, 1, 1, 9, 5, colors.lime, colors.blue)
  20. t:add ("close", nil, 10, 1, 18, 5, colors.red, colors.blue)
  21. t:draw()
  22.  
  23. while true do
  24.     local event, p1 = t:handleEvents(os.pullEvent())
  25.     if event == "button_click" then
  26.         t:flash(p1)
  27.         if p1 == "open" and door == "closed" then
  28.             doorOpen()
  29.         elseif p1 == "close" and door == "open" then
  30.             doorClose()
  31.         end
  32.     end
  33. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement