Advertisement
awesome8digger

ComputerCraft Elevator ElevatorSide

Jul 12th, 2018
109
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.80 KB | None | 0 0
  1. modemSide = "top"
  2. controlComputerID = 6
  3.  
  4. callComputerID1 = 28
  5. callComputerID2 = 99
  6. callComputerID3 = 99
  7. callComputerID4 = 99
  8. callComputerID5 = 99
  9. callComputerID6 = 99
  10.  
  11. rednet.open(modemSide)
  12. function UserInput()
  13.     term.clear()
  14.     term.setCursorPos(1,1)
  15.     outputFloor()
  16.     print("Enter The Floor Number You Want To Go To")
  17.     while true do
  18.         local input = read()
  19.    
  20.         if input == "1" then
  21.             calculateFloors(1)
  22.             break
  23.         elseif input == "2" then
  24.             calculateFloors(2)
  25.             break
  26.         elseif input == "3" then
  27.             calculateFloors(3)
  28.             break
  29.         elseif input == "4" then
  30.             calculateFloors(4)
  31.             break
  32.         elseif input == "5" then
  33.             calculateFloors(5)
  34.             break
  35.         elseif input == "6" then
  36.             calculateFloors(6)
  37.             break
  38.         elseif input == "DebugUp" then
  39.             rednet.send(controlComputerID, input)
  40.             UserInput()
  41.             break
  42.         elseif input == "DebugDown" then
  43.             rednet.send(controlComputerID, input)
  44.             UserInput()
  45.             break
  46.         end
  47.     end
  48. end
  49.  
  50. function outputFloor()
  51.     local floorSignal = redstone.getAnalogInput("back")
  52.     if floorSignal ~= 0 then
  53.         rednet.send(callComputerID1, floorSignal)
  54.         rednet.send(callComputerID2, floorSignal)
  55.         rednet.send(callComputerID3, floorSignal)
  56.         rednet.send(callComputerID4, floorSignal)
  57.         rednet.send(callComputerID5, floorSignal)
  58.         rednet.send(callComputerID6, floorSignal)
  59.     end
  60. end
  61.  
  62. function calculateFloors(desiredFloor)
  63.     local floorDifference = getCurrentFloor() - desiredFloor
  64.     if floorDifference == 0 then
  65.         UserInput()
  66.     end
  67.     rednet.send(controlComputerID, floorDifference)
  68.     UserInput()
  69. end
  70.  
  71. function getCurrentFloor()
  72.     local signal = redstone.getAnalogInput("back")
  73.     if signal == 0 then
  74.         print("Not Currently On A Floor. Type DebugUp Or DebugDown To Move Up Or Down One Block")
  75.         os.sleep(5)
  76.         UserInput()
  77.     else
  78.         return signal
  79.     end
  80. end
  81.  
  82. UserInput()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement