Advertisement
awesome8digger

Computercraft Elevator ControlSide

Jul 12th, 2018
91
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.76 KB | None | 0 0
  1. cableSide = "right"
  2. modemSide = "top"
  3.  
  4. function main()
  5.     rednet.open("top")
  6.     id, message = rednet.receive()
  7.     if message == "DebugUp" then
  8.         Up()
  9.         main()
  10.     elseif message == "DebugDown" then
  11.         Down()
  12.         main()
  13.     elseif message > 0 then
  14.         for i = 1, message do
  15.             UpFloor()
  16.         end
  17.         main()
  18.     else
  19.         for i = 1, math.abs(message) do
  20.             DownFloor()
  21.         end
  22.         main()
  23.     end
  24.     main()
  25. end
  26.  
  27. function UpFloor()
  28.     for f = 1, 10 do
  29.         Up()
  30.     end
  31. end
  32.  
  33. function DownFloor()
  34.     for f = 1, 10 do
  35.         Down()
  36.     end
  37. end
  38.  
  39. function Up()
  40.     redstone.setBundledOutput(cableSide, 1)
  41.     os.sleep(1.05)
  42.     redstone.setBundledOutput(cableSide, 0)
  43. end
  44.  
  45. function Down()
  46.     redstone.setBundledOutput(cableSide, 2)
  47.     os.sleep(1.05)
  48.     redstone.setBundledOutput(cableSide, 0)
  49. end
  50.  
  51. main()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement