Advertisement
Jobs2k

Elevator

Sep 24th, 2017
105
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.49 KB | None | 0 0
  1. local term = require("term")
  2. local gpu = require("component").proxy("gpu")
  3. local button = require("component").proxy("dc1f7a58-4c50-489f-86bb-a6bcc3419bd4")
  4. local floor = require("component").proxy("0c14f10e-d910-4e05-b478-9c9f8accab6c")
  5. local ele = require("component").proxy("ddd486f4-dd98-4fa4-8ca8-dff0e8909499")
  6. local door = require("component").proxy("9bce80eb-6f12-48fc-97d7-1521156d2a63")
  7. local event = require("event")
  8.  
  9. --for a=0,15 do
  10. --    button.setBundledOutput(3,a,0)
  11. --    floor.setBundledOutput(3,a,0)
  12.     ele.setBundledOutput(3,a,0)
  13.     door.setBundledOutput(3,a,0)
  14. --end
  15.  
  16. function screenCheck(_,_,eventX,eventY)
  17.     if eventX ~= nil then
  18.         print("Event registered at "..eventX.." / "..eventY)
  19. end end
  20.  
  21. event.listen("touch",screenCheck)
  22.  
  23. function buttonCheck ()
  24.     for a=0,15 do
  25.         if button.getBundledInput(3,a) ~= 0 then
  26.             idling = 0
  27.             moveTo(a)
  28. --            button.setBundledOutput(3,a,0)
  29. end end end
  30.  
  31. function moveTo (a)
  32.     ele.setBundledOutput(3,a,15)
  33.     os.sleep(0.1)
  34.     ele.setBundledOutput(3,a,0)
  35. end
  36.  
  37. function doors ()
  38.     for a=0,15 do
  39.         if floor.getBundledInput(3,a) ~= 0 then
  40.             door.setBundledOutput(3,a,15)
  41.             os.sleep(5)
  42.             door.setBundledOutput(3,a,0)
  43.             idling = 1
  44. end end end
  45.  
  46. idling = 1
  47.  
  48. while true do
  49.  
  50.     if idling == 1 then
  51.         buttonCheck()
  52.         screenCheck()
  53.     end
  54.     if idling == 0 then
  55.         doors()
  56.     end
  57.     os.sleep(0.01)
  58. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement