MysteryDump

MysteryDump's Railcraft Elevator Server v1.4a

Mar 16th, 2014
272
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 48.88 KB | None | 0 0
  1. --  RAILCRAFT ELEVATOR SERVER "A" VERSION 1.4 MARCH 13TH 2014
  2. --  DESIGNED AND WRITTEN BY "MYSTERYDUMP"
  3. --  WWW.MYSTERYDUMP.COM
  4.  
  5.  
  6. --  ****IMPORTANT**** THIS IS THE "A" VERSION OF THE SERVER SOFTWARE AND MUST BE USED WITH THE "A" VERSIONS OF THE ELEVATOR "MONITOR PROGRAM" AND THE "A" VERSION OF THE ELEVATOR CLIENTS! IF YOU NEED HELP BUILDING AND/OR INSTALLING THE ELEVATOR AND THE SERVER/MONITOR/CLIENT PROGRAMS AND THEN CONFIGURING THEM, GO TO MYSTERYDUMP.COM/ELEVATOR FOR HELP.
  7.  
  8.  
  9.  
  10.  
  11.  
  12.  
  13.  
  14.  
  15.  
  16.  
  17.  
  18. --- MODEM SETUP
  19.  
  20.     rednet.open("top")
  21.    
  22.  
  23.  
  24.  
  25.  
  26.  
  27.  
  28.  
  29.  
  30.  
  31.  
  32. -- SET BUNDLED CABLES AND INITIALIZE IN/OUTPUTS (OFF)
  33.  
  34.  
  35.     local cablePort1 = "right"
  36.     local cablePort2 = "left"
  37.     rs.setBundledOutput(cablePort1, 0 )
  38.     rs.setBundledOutput(cablePort2, 0 )
  39.  
  40.  
  41.  
  42.  
  43.  
  44.  
  45.  
  46.  
  47.  
  48.  
  49.  
  50. -- LOCALS
  51.  
  52.  
  53.     local powerSwitch = 0
  54.     local powerStatus = "Testing"
  55.  
  56.  
  57.  
  58.     local computerID7 = 116  --  FLOOR 7    <---- SET COMPUTER ID'S OF EACH COMPUTER CLIENT HERE  *******ALSO NEEDS CHANGED IN THE txData Section!!!!!!*********
  59.     local computerID6 = 113  --  FLOOR 6   
  60.     local computerID5 = 112  --  FLOOR 5   
  61.     local computerID4 = 108  --  FLOOR 4   
  62.     local computerID3 = 107  --  FLOOR 3   
  63.     local computerID2 = 105  --  FLOOR 2   
  64.     local computerID1 = 103  --  FLOOR 1   
  65.  
  66.  
  67.  
  68.     local clientID = 0
  69.  
  70.     local buttonPad1 = 0  -- <---- Client transmits 1-7 to server for button pressed
  71.     local buttonPad2 = 0
  72.     local buttonPad3 = 0
  73.     local buttonPad4 = 0
  74.     local buttonPad5 = 0
  75.     local buttonPad6 = 0
  76.     local buttonPad7 = 0
  77.  
  78.  
  79.  
  80.     local token1 = 0  --  <---- - Tells the client 0=Standby 1=Ready 2=Busy 3=Hold
  81.     local token2 = 0
  82.     local token3 = 0
  83.     local token4 = 0
  84.     local token5 = 0
  85.     local token6 = 0
  86.     local token7 = 0
  87.  
  88.     local messageID1 = 0  -- <---- These are used to tell the client which message it is and which set of instruction code to use
  89.     local messageID2 = 0
  90.     local messageID3 = 0
  91.     local messageID4 = 0
  92.     local messageID5 = 0
  93.     local messageID6 = 0
  94.     local messageID7 = 0
  95.  
  96.     local elevatorKey1 = 1  -- <---- 1 = KEY (ON), 0 = KEY (OFF)
  97.     local elevatorKey2 = 1
  98.     local elevatorKey3 = 1
  99.     local elevatorKey4 = 1
  100.     local elevatorKey5 = 1
  101.     local elevatorKey6 = 1
  102.     local elevatorKey7 = 1
  103.  
  104.  
  105.  
  106.  
  107.  
  108.  
  109.  
  110.  
  111. -- CART SENSOR DATA
  112.  
  113.     local cartSensorData = {}
  114.         cartSensorData[1] = false
  115.         cartSensorData[2] = false
  116.         cartSensorData[3] = false
  117.         cartSensorData[4] = false
  118.         cartSensorData[5] = false
  119.         cartSensorData[6] = false
  120.         cartSensorData[7] = false
  121.  
  122.     local cartSensorAnswer1 = "FALSE"
  123.     local cartSensorAnswer2 = "FALSE"
  124.     local cartSensorAnswer3 = "FALSE"
  125.     local cartSensorAnswer4 = "FALSE"
  126.     local cartSensorAnswer5 = "FALSE"
  127.     local cartSensorAnswer6 = "FALSE"
  128.     local cartSensorAnswer7 = "FALSE"
  129.  
  130.  
  131.  
  132.  
  133.  
  134.  
  135.  
  136.  
  137.  
  138.  
  139.  
  140.  
  141.  
  142.  
  143.  
  144.  
  145.  
  146.  
  147.  
  148.  
  149.  
  150. -- TX DATA PACKETS
  151.  
  152.     local dataTXPacket = {}
  153.  
  154.         dataTXPacket[0] = (powerSwitch)
  155.  
  156.         dataTXPacket[1] = (token7)      -- <------ ******* TX Created on Server - (token1) - it tells the client 0=Standby 1=Ready 2=Busy 3=Hold
  157.         dataTXPacket[2] = (messageID7)      -- <------ ******* TX Created on Server - (messageID1) - Sets of Server instructions to clients.
  158.         dataTXPacket[3] = (elevatorKey7)    -- <------ ******* TX Created on Server - (elevatorKey1) - Turns Client ON or OFF operation (needs powerSwitch + Key to operate)
  159.  
  160.         dataTXPacket[4] = (token6)
  161.         dataTXPacket[5] = (messageID6)
  162.         dataTXPacket[6] = (elevatorKey6)
  163.  
  164.         dataTXPacket[7] = (token5)
  165.         dataTXPacket[8] = (messageID5)
  166.         dataTXPacket[9] = (elevatorKey5)
  167.  
  168.         dataTXPacket[10] = (token4)
  169.         dataTXPacket[11] = (messageID4)
  170.         dataTXPacket[12] = (elevatorKey4)
  171.  
  172.         dataTXPacket[13] = (token3)
  173.         dataTXPacket[14] = (messageID3)
  174.         dataTXPacket[15] = (elevatorKey3)
  175.  
  176.         dataTXPacket[16] = (token2)
  177.         dataTXPacket[17] = (messageID2)
  178.         dataTXPacket[18] = (elevatorKey2)
  179.  
  180.         dataTXPacket[19] = (token1)
  181.         dataTXPacket[20] = (messageID1)
  182.         dataTXPacket[21] = (elevatorKey1)
  183.  
  184.  
  185.  
  186.  
  187.  
  188. --------------------- Transmit DATA via RedNet (PARALLEL FUNCTION) -----------------------
  189.  
  190.  
  191. txData = function()
  192.  
  193.  
  194.  
  195.     while true do  
  196.     sleep(0)
  197.  
  198.         dataTXPacket[0] = (powerSwitch)
  199.  
  200.         dataTXPacket[1] = (token7)
  201.         dataTXPacket[2] = (messageID7)
  202.         dataTXPacket[3] = (elevatorKey7)
  203.  
  204.         dataTXPacket[4] = (token6)
  205.         dataTXPacket[5] = (messageID6)
  206.         dataTXPacket[6] = (elevatorKey6)
  207.  
  208.         dataTXPacket[7] = (token5)
  209.         dataTXPacket[8] = (messageID5)
  210.         dataTXPacket[9] = (elevatorKey5)
  211.  
  212.         dataTXPacket[10] = (token4)
  213.         dataTXPacket[11] = (messageID4)
  214.         dataTXPacket[12] = (elevatorKey4)
  215.  
  216.         dataTXPacket[13] = (token3)
  217.         dataTXPacket[14] = (messageID3)
  218.         dataTXPacket[15] = (elevatorKey3)
  219.  
  220.         dataTXPacket[16] = (token2)
  221.         dataTXPacket[17] = (messageID2)
  222.         dataTXPacket[18] = (elevatorKey2)
  223.  
  224.         dataTXPacket[19] = (token1)
  225.         dataTXPacket[20] = (messageID1)
  226.         dataTXPacket[21] = (elevatorKey1)
  227.        
  228.         local txMsg = textutils.serialize(dataTXPacket)
  229.  
  230.  
  231.  
  232.         rednet.send(116, txMsg)  --  FLOOR 7 <----- NEED TO UPDATE THESE WITH THE COMPUTER ID'S OF EACH COMPUTER (STUPID REDNET API WON'T ALLOW A SET VARIABLE TO BE ADDED)
  233.         rednet.send(113, txMsg)  --  FLOOR 6 <----- NEED TO UPDATE THESE WITH THE COMPUTER ID'S OF EACH COMPUTER (STUPID REDNET API WON'T ALLOW A SET VARIABLE TO BE ADDED)
  234.         rednet.send(112, txMsg)  --  FLOOR 5 <----- NEED TO UPDATE THESE WITH THE COMPUTER ID'S OF EACH COMPUTER (STUPID REDNET API WON'T ALLOW A SET VARIABLE TO BE ADDED)
  235.         rednet.send(108, txMsg)  --  FLOOR 4 <----- NEED TO UPDATE THESE WITH THE COMPUTER ID'S OF EACH COMPUTER (STUPID REDNET API WON'T ALLOW A SET VARIABLE TO BE ADDED)
  236.         rednet.send(107, txMsg)  --  FLOOR 3 <----- NEED TO UPDATE THESE WITH THE COMPUTER ID'S OF EACH COMPUTER (STUPID REDNET API WON'T ALLOW A SET VARIABLE TO BE ADDED)
  237.         rednet.send(105, txMsg)  --  FLOOR 2 <----- NEED TO UPDATE THESE WITH THE COMPUTER ID'S OF EACH COMPUTER (STUPID REDNET API WON'T ALLOW A SET VARIABLE TO BE ADDED)
  238.         rednet.send(103, txMsg)  --  FLOOR 1 <----- NEED TO UPDATE THESE WITH THE COMPUTER ID'S OF EACH COMPUTER (STUPID REDNET API WON'T ALLOW A SET VARIABLE TO BE ADDED)
  239.  
  240.  
  241.  
  242.  
  243.  
  244.  
  245.  
  246.  
  247.     end
  248. end
  249.  
  250.  
  251.  
  252.  
  253.  
  254.  
  255.  
  256.  
  257.  
  258.  
  259.  
  260.  
  261.  
  262.  
  263.  
  264.  
  265.  
  266.  
  267.  
  268.  
  269.  
  270. --------------------- Receive DATA via RedNet (PARALLEL FUNCTION) -----------------------
  271.  
  272.  
  273.  
  274.  
  275.     local dataRXPacket = {}
  276.         dataRXPacket[0] = 0
  277.         dataRXPacket[1] = 0
  278.         dataRXPacket[2] = 0
  279.         dataRXPacket[3] = 0
  280.  
  281.  
  282.  
  283.  
  284.  
  285.  
  286. rxData = function()
  287.  
  288.     while true do
  289.     sleep(0)
  290.  
  291.  
  292.     local senderID, message = rednet.receive()
  293.  
  294.     dataRXPacket = textutils.unserialize(message)
  295.  
  296.  
  297.  
  298.         if senderID == (computerID1) then
  299.             clientID = 1
  300.             buttonPad1 = (dataRXPacket[2])
  301.         end
  302.  
  303.         if senderID == (computerID2) then
  304.             clientID = 2
  305.             buttonPad2 = (dataRXPacket[2])
  306.         end
  307.    
  308.         if senderID == (computerID3) then
  309.             clientID = 3
  310.             buttonPad3 = (dataRXPacket[2])
  311.         end
  312.  
  313.         if senderID == (computerID4) then
  314.             buttonPad4 = (dataRXPacket[2])
  315.             clientID = 4
  316.         end
  317.  
  318.         if senderID == (computerID5) then
  319.             clientID = 5
  320.             buttonPad5 = (dataRXPacket[2])
  321.         end
  322.    
  323.         if senderID == (computerID6) then
  324.             clientID = 6
  325.             buttonPad6 = (dataRXPacket[2])
  326.         end
  327.  
  328.         if senderID == (computerID7) then
  329.             clientID = 7
  330.             buttonPad7 = (dataRXPacket[2])
  331.         end
  332.  
  333.  
  334.  
  335.  
  336.  
  337.     end
  338. end
  339.  
  340.  
  341.  
  342. ------------------------------- CART SENSORS (PARALLEL FUNCTION) -------------------------------
  343.  
  344.  
  345.  
  346. cartSensor = function()
  347.  
  348.  
  349.         while true do
  350.         sleep(0)
  351.  
  352.             sensor07 = redstone.testBundledInput(cablePort2, colors.white)
  353.  
  354.                     if sensor07 == true then
  355.                         cartSensorData[7] = true
  356.                         cartSensorAnswer7 = "TRUE "
  357.                         term.setCursorPos(31,5)
  358.                         print (cartSensorAnswer7)
  359.                     else
  360.                         term.setCursorPos(31,5)
  361.                         cartSensorData[7] = false
  362.                         cartSensorAnswer7 = "FALSE"
  363.                         print (cartSensorAnswer7)
  364.                     end
  365.  
  366.  
  367.             sensor06 = redstone.testBundledInput(cablePort2, colors.magenta)
  368.  
  369.                     if sensor06 == true then
  370.                         cartSensorData[6] = true
  371.                         cartSensorAnswer6 = "TRUE "
  372.                         term.setCursorPos(31,6)
  373.                         print (cartSensorAnswer6)
  374.                     else
  375.                         term.setCursorPos(31,6)
  376.                         cartSensorData[6] = false
  377.                         cartSensorAnswer6 = "FALSE"
  378.                         print (cartSensorAnswer6)
  379.                     end
  380.  
  381.  
  382.             sensor05 = redstone.testBundledInput(cablePort2, colors.yellow)
  383.  
  384.                     if sensor05 == true then
  385.                         cartSensorData[5] = true
  386.                         cartSensorAnswer5 = "TRUE "
  387.                         term.setCursorPos(31,7)
  388.                         print (cartSensorAnswer5)
  389.                     else
  390.                         term.setCursorPos(31,7)
  391.                         cartSensorData[5] = false
  392.                         cartSensorAnswer5 = "FALSE"
  393.                         print (cartSensorAnswer5)
  394.                     end
  395.  
  396.  
  397.             sensor04 = redstone.testBundledInput(cablePort2, colors.pink)
  398.  
  399.                     if sensor04 == true then
  400.                         cartSensorData[4] = true
  401.                         cartSensorAnswer4 = "TRUE "
  402.                         term.setCursorPos(31,8)
  403.                         print (cartSensorAnswer4)
  404.                     else
  405.                         term.setCursorPos(31,8)
  406.                         cartSensorData[4] = false
  407.                         cartSensorAnswer4 = "FALSE"
  408.                         print (cartSensorAnswer4)
  409.                     end
  410.  
  411.  
  412.             sensor03 = redstone.testBundledInput(cablePort2, colors.lightGray)
  413.  
  414.                     if sensor03 == true then
  415.                         cartSensorData[3] = true
  416.                         cartSensorAnswer3 = "TRUE "
  417.                         term.setCursorPos(31,9)
  418.                         print (cartSensorAnswer3)
  419.                     else
  420.                         term.setCursorPos(31,9)
  421.                         cartSensorData[3] = false
  422.                         cartSensorAnswer3 = "FALSE"
  423.                         print (cartSensorAnswer3)
  424.                     end
  425.  
  426.  
  427.             sensor02 = redstone.testBundledInput(cablePort2, colors.purple)
  428.  
  429.                     if sensor02 == true then
  430.                         cartSensorData[2] = true
  431.                         cartSensorAnswer2 = "TRUE "
  432.                         term.setCursorPos(31,10)
  433.                         print (cartSensorAnswer2)
  434.                     else
  435.                         term.setCursorPos(31,10)
  436.                         cartSensorData[2] = false
  437.                         cartSensorAnswer2 = "FALSE"
  438.                         print (cartSensorAnswer2)
  439.                     end
  440.  
  441.  
  442.             sensor01 = redstone.testBundledInput(cablePort2, colors.brown)
  443.  
  444.                     if sensor01 == true then
  445.                         cartSensorData[1] = true
  446.                         cartSensorAnswer1 = "TRUE "
  447.                         term.setCursorPos(31,11)
  448.                         print (cartSensorAnswer1)
  449.                     else
  450.                         term.setCursorPos(31,11)
  451.                         cartSensorData[1] = false
  452.                         cartSensorAnswer1 = "FALSE"
  453.                         print (cartSensorAnswer1)
  454.                     end
  455.         end
  456. end
  457.  
  458.  
  459.  
  460.  
  461.  
  462.  
  463.  
  464.  
  465.  
  466.  
  467.  
  468.  
  469.  
  470.  
  471.  
  472.  
  473. --------------------- POWER SWITCH (PARALLEL FUNCTION) ---------------------
  474.  
  475.  
  476. checkPower = function()
  477.  
  478.     while true do
  479.  
  480.         sleep(0)
  481.  
  482.         local power = redstone.testBundledInput(cablePort1, colors.green)
  483.  
  484.         if power == true then
  485.         powerSwitch = 1
  486.         powerStatus = "ONLINE "
  487.  
  488.         else
  489.  
  490.         powerSwitch = 0
  491.         powerStatus = "OFFLINE"
  492.  
  493.         end
  494.     end
  495. end
  496.  
  497.  
  498.  
  499.  
  500.  
  501.  
  502.  
  503.  
  504.  
  505.  
  506.  
  507.  
  508.  
  509. ----------------- SCREEN COMMANDS (PARALLEL FUNCTION) ----------------
  510.  
  511.  
  512.  
  513. ScreenCommands = function()
  514.  
  515.        
  516.             term.setCursorPos(33,1)
  517.             print "         Reboot [R]"
  518.  
  519.  
  520.             term.setCursorPos(1,18)
  521.             print ("Elevator Button: [1] [2] [3] [4] [5] [6] [7]")
  522.  
  523.  
  524.     while true do
  525.  
  526.  
  527.             local event1, param1 = os.pullEvent ("char")
  528.  
  529.  
  530.            
  531.  
  532.             if param1 == "1" then
  533.  
  534.                     if powerSwitch == 0 then
  535.                         term.setCursorPos(1,16)
  536.                         term.clearLine()
  537.                         print "REQUEST DECLINED: System Power is OFFLINE"
  538.                         sleep(2)
  539.                         term.setCursorPos(1,16)
  540.                         term.clearLine()
  541.  
  542.                     else
  543.    
  544.                         button1send()                   --  <------------------------- SENDS CART TO FLOOR [1]
  545.                         term.setCursorPos(1,16)
  546.                         term.clearLine()
  547.                         print "Elevator Cart is now on Floor 1"
  548.                         sleep(2)
  549.                         term.setCursorPos(1,16)
  550.                         term.clearLine()
  551.                         buttonwait1()
  552.                                 token1 = 0  --  <---- - Tells the client 0=Standby 1=Ready 2=Busy 3=Hold
  553.                                 token2 = 0
  554.                                 token3 = 0
  555.                                 token4 = 0
  556.                                 token5 = 0
  557.                                 token6 = 0
  558.                                 token7 = 0
  559.                     end
  560.             end
  561.  
  562.  
  563.  
  564.  
  565.  
  566.  
  567.  
  568.  
  569.             if param1 == "2" then
  570.  
  571.                     if powerSwitch == 0 then
  572.                         term.setCursorPos(1,16)
  573.                         term.clearLine()
  574.                         print "REQUEST DECLINED: System Power is OFFLINE"
  575.                         sleep(2)
  576.                         term.setCursorPos(1,16)
  577.                         term.clearLine()
  578.  
  579.                     else
  580.    
  581.                         button2send()                   --  <------------------------- SENDS CART TO FLOOR [2]
  582.                         term.setCursorPos(1,16)
  583.                         term.clearLine()
  584.                         print "Elevator Cart is now on Floor 2"
  585.                         sleep(2)
  586.                         term.setCursorPos(1,16)
  587.                         term.clearLine()
  588.                         buttonwait2()
  589.                                 token1 = 0  --  <---- - Tells the client 0=Standby 1=Ready 2=Busy 3=Hold
  590.                                 token2 = 0
  591.                                 token3 = 0
  592.                                 token4 = 0
  593.                                 token5 = 0
  594.                                 token6 = 0
  595.                                 token7 = 0
  596.                     end
  597.             end
  598.  
  599.  
  600.  
  601.  
  602.             if param1 == "3" then
  603.  
  604.  
  605.                     if powerSwitch == 0 then
  606.                         term.setCursorPos(1,16)
  607.                         term.clearLine()
  608.                         print "REQUEST DECLINED: System Power is OFFLINE"
  609.                         sleep(2)
  610.                         term.setCursorPos(1,16)
  611.                         term.clearLine()
  612.  
  613.                     else
  614.    
  615.                         button3send()                   --  <------------------------- SENDS CART TO FLOOR [3]
  616.                         term.setCursorPos(1,16)
  617.                         term.clearLine()
  618.                         print "Elevator Cart is now on Floor 3"
  619.                         sleep(2)
  620.                         term.setCursorPos(1,16)
  621.                         term.clearLine()
  622.                         buttonwait3()
  623.                                 token1 = 0  --  <---- - Tells the client 0=Standby 1=Ready 2=Busy 3=Hold
  624.                                 token2 = 0
  625.                                 token3 = 0
  626.                                 token4 = 0
  627.                                 token5 = 0
  628.                                 token6 = 0
  629.                                 token7 = 0
  630.                     end
  631.             end
  632.  
  633.  
  634.  
  635.  
  636.             if param1 == "4" then
  637.  
  638.                     if powerSwitch == 0 then
  639.                         term.setCursorPos(1,16)
  640.                         term.clearLine()
  641.                         print "REQUEST DECLINED: System Power is OFFLINE"
  642.                         sleep(2)
  643.                         term.setCursorPos(1,16)
  644.                         term.clearLine()
  645.  
  646.                     else
  647.    
  648.                         button4send()                   --  <------------------------- SENDS CART TO FLOOR [4]
  649.                         term.setCursorPos(1,16)
  650.                         term.clearLine()
  651.                         print "Elevator Cart is now on Floor 4"
  652.                         sleep(2)
  653.                         term.setCursorPos(1,16)
  654.                         term.clearLine()
  655.                         buttonwait4()
  656.                                 token1 = 0  --  <---- - Tells the client 0=Standby 1=Ready 2=Busy 3=Hold
  657.                                 token2 = 0
  658.                                 token3 = 0
  659.                                 token4 = 0
  660.                                 token5 = 0
  661.                                 token6 = 0
  662.                                 token7 = 0
  663.                     end
  664.             end
  665.  
  666.  
  667.  
  668.  
  669.             if param1 == "5" then
  670.  
  671.                     if powerSwitch == 0 then
  672.                         term.setCursorPos(1,16)
  673.                         term.clearLine()
  674.                         print "REQUEST DECLINED: System Power is OFFLINE"
  675.                         sleep(2)
  676.                         term.setCursorPos(1,16)
  677.                         term.clearLine()
  678.  
  679.                     else
  680.  
  681.                         button5send()                   --  <------------------------- SENDS CART TO FLOOR [5]
  682.                         term.setCursorPos(1,16)
  683.                         term.clearLine()
  684.                         print "Elevator Cart is now on Floor 5"
  685.                         sleep(2)
  686.                         term.setCursorPos(1,16)
  687.                         term.clearLine()
  688.                         buttonwait5()
  689.                                 token1 = 0  --  <---- - Tells the client 0=Standby 1=Ready 2=Busy 3=Hold
  690.                                 token2 = 0
  691.                                 token3 = 0
  692.                                 token4 = 0
  693.                                 token5 = 0
  694.                                 token6 = 0
  695.                                 token7 = 0
  696.                     end
  697.             end
  698.  
  699.  
  700.  
  701.  
  702.             if param1 == "6" then
  703.  
  704.                     if powerSwitch == 0 then
  705.                         term.setCursorPos(1,16)
  706.                         term.clearLine()
  707.                         print "REQUEST DECLINED: System Power is OFFLINE"
  708.                         sleep(2)
  709.                         term.setCursorPos(1,16)
  710.                         term.clearLine()
  711.  
  712.                     else
  713.    
  714.                         button6send()                   --  <------------------------- SENDS CART TO FLOOR [6]
  715.                         term.setCursorPos(1,16)
  716.                         term.clearLine()
  717.                         print "Elevator Cart is now on Floor 6"
  718.                         sleep(2)
  719.                         term.setCursorPos(1,16)
  720.                         term.clearLine()
  721.                         buttonwait6()
  722.                                 token1 = 0  --  <---- - Tells the client 0=Standby 1=Ready 2=Busy 3=Hold
  723.                                 token2 = 0
  724.                                 token3 = 0
  725.                                 token4 = 0
  726.                                 token5 = 0
  727.                                 token6 = 0
  728.                                 token7 = 0
  729.                     end
  730.             end
  731.  
  732.  
  733.  
  734.  
  735.             if param1 == "7" then
  736.  
  737.                     if powerSwitch == 0 then
  738.                         term.setCursorPos(1,16)
  739.                         term.clearLine()
  740.                         print "REQUEST DECLINED: System Power is OFFLINE"
  741.                         sleep(2)
  742.                         term.setCursorPos(1,16)
  743.                         term.clearLine()
  744.  
  745.                     else
  746.  
  747.                         button7send()                   --  <------------------------- SENDS CART TO FLOOR [7]
  748.                         term.setCursorPos(1,16)
  749.                         term.clearLine()
  750.                         print "Elevator Cart is now on Floor 7"
  751.                         sleep(2)
  752.                         term.setCursorPos(1,16)
  753.                         term.clearLine()
  754.                         buttonwait7()
  755.                                 token1 = 0  --  <---- - Tells the client 0=Standby 1=Ready 2=Busy 3=Hold
  756.                                 token2 = 0
  757.                                 token3 = 0
  758.                                 token4 = 0
  759.                                 token5 = 0
  760.                                 token6 = 0
  761.                                 token7 = 0
  762.                     end
  763.             end
  764.  
  765.  
  766.  
  767.  
  768.  
  769.  
  770.             if param1 == "r" then           --  <------------------------- REBOOT SERVER COMMAND [r]
  771.                 term.setCursorPos(33,1)
  772.                 print "Are you sure? [Y/N]"
  773.  
  774.                     local event2, param2 = os.pullEvent ("char")
  775.  
  776.                     if param2 == "y" then
  777.                         term.setCursorPos(33,1)
  778.                         print ("       Rebooting...")
  779.                         sleep (1.5)
  780.                         os.reboot()
  781.  
  782.                     elseif param2 == "Y" then
  783.                         term.setCursorPos(33,1)
  784.                         print ("       Rebooting...")
  785.                         sleep (1.5)
  786.                         os.reboot()
  787.  
  788.                     elseif param2 == "n" then
  789.                         term.setCursorPos(33,1)
  790.                         print "         Reboot [R]"
  791.  
  792.                    
  793.                     elseif param2 == "N" then
  794.                         term.setCursorPos(33,1)
  795.                         print "         Reboot [R]"
  796.  
  797.  
  798.                     else
  799.                         term.setCursorPos(33,1)
  800.                         print ("     Invalid Choice")
  801.                         sleep (1.5)
  802.                         term.setCursorPos(33,1)
  803.                         print "         Reboot [R]"
  804.                     end
  805.             end
  806.  
  807.  
  808.             if param1 == "R" then           --  <------------------------- REBOOT SERVER COMMAND [R]
  809.                 term.setCursorPos(33,1)
  810.                 print "Are you sure? [Y/N]"
  811.  
  812.                     local event2, param2 = os.pullEvent ("char")
  813.  
  814.                     if param2 == "y" then
  815.                         term.setCursorPos(33,1)
  816.                         print ("       Rebooting...")
  817.                         sleep (1.5)
  818.                         os.reboot()
  819.  
  820.                     elseif param2 == "Y" then
  821.                         term.setCursorPos(33,1)
  822.                         print ("       Rebooting...")
  823.                         sleep (1.5)
  824.                         os.reboot()
  825.  
  826.                     elseif param2 == "n" then
  827.                         term.setCursorPos(33,1)
  828.                         print "         Reboot [R]"
  829.  
  830.                    
  831.                     elseif param2 == "N" then
  832.                         term.setCursorPos(33,1)
  833.                         print "         Reboot [R]"
  834.  
  835.  
  836.                     else
  837.                         term.setCursorPos(33,1)
  838.                         print ("     Invalid Choice")
  839.                         sleep (1.5)
  840.                         term.setCursorPos(33,1)
  841.                         print "         Reboot [R]"
  842.                     end
  843.             end
  844.     end
  845. end
  846.  
  847.  
  848.  
  849.  
  850.  
  851.  
  852.  
  853. --------------------- SCREEN (PARALLEL FUNCTION) ---------------------
  854.  
  855.  
  856. screen = function()
  857.  
  858.  
  859.     while true do
  860.     sleep(0)
  861.  
  862.  
  863.  
  864. term.setCursorPos(1,1)
  865.         print "Elevator Control System v1.4a"
  866.    
  867.  
  868.         term.setCursorPos(1,3)
  869.         term.clearLine()
  870.         print ("System Power: ", powerStatus)
  871.  
  872.         local time = os.time()              -- <-------------- Onscreen Clock
  873.         local day = os.day()
  874.  
  875.         time = textutils.formatTime(time, false)
  876.         term.setCursorPos(27,3)             -- <-------------- AJUST THIS LINE NUMBER IS THE "DAY" COUNT IS SPILLING OVER ONTO ANOTHER LINE.
  877.         print("Day:", day, " Time: ", time)
  878.  
  879.  
  880.         term.setCursorPos(1,13)
  881.         print ("Client ID Communicating: ", clientID)
  882.  
  883.  
  884.  
  885.  
  886.  
  887.  
  888.  
  889. --------------------- SCREEN / FLOOR 7 ---------------------
  890.  
  891.  
  892.         term.setCursorPos(4,5)
  893.         print "Floor 7:"
  894.  
  895.             if token7 == 0 then             --  <---- - Tells the client 0=Standby 1=Active 2=Busy 3=Hold
  896.                 term.setCursorPos(13,5)
  897.                 print "STANDBY"
  898.             end
  899.             if token7 == 1 then
  900.                 term.setCursorPos(13,5)
  901.                 print "READY "
  902.             end
  903.             if token7 == 2 then
  904.                 term.setCursorPos(13,5)
  905.                 print "BUSY   "
  906.             end
  907.             if token7 == 3 then
  908.                 term.setCursorPos(13,5)
  909.                 print "HOLD   "
  910.             end
  911.  
  912.         term.setCursorPos(23,5)
  913.         print "Sensor:"
  914.  
  915.         term.setCursorPos(39,5)
  916.         print ("Button: ", buttonPad7) 
  917.  
  918.  
  919.  
  920. --------------------- SCREEN / FLOOR 6 ---------------------
  921.  
  922.  
  923.         term.setCursorPos(4,6)
  924.         print "Floor 6:"
  925.  
  926.             if token6 == 0 then
  927.                 term.setCursorPos(13,6)
  928.                 print "STANDBY"
  929.             end
  930.             if token6 == 1 then
  931.                 term.setCursorPos(13,6)
  932.                 print "READY "
  933.             end
  934.             if token6 == 2 then
  935.                 term.setCursorPos(13,6)
  936.                 print "BUSY   "
  937.             end
  938.             if token6 == 3 then
  939.                 term.setCursorPos(13,6)
  940.                 print "HOLD   "
  941.             end
  942.  
  943.         term.setCursorPos(23,6)
  944.         print "Sensor:"
  945.  
  946.         term.setCursorPos(39,6)
  947.         print ("Button: ", buttonPad6)
  948.  
  949.  
  950.  
  951. --------------------- SCREEN / FLOOR 5 ---------------------
  952.  
  953.  
  954.         term.setCursorPos(4,7)
  955.         print "Floor 5:"
  956.  
  957.             if token5 == 0 then
  958.                 term.setCursorPos(13,7)
  959.                 print "STANDBY"
  960.             end
  961.             if token5 == 1 then
  962.                 term.setCursorPos(13,7)
  963.                 print "READY "
  964.             end
  965.             if token5 == 2 then
  966.                 term.setCursorPos(13,7)
  967.                 print "BUSY   "
  968.             end
  969.             if token5 == 3 then
  970.                 term.setCursorPos(13,7)
  971.                 print "HOLD   "
  972.             end
  973.  
  974.         term.setCursorPos(23,7)
  975.         print "Sensor:"
  976.  
  977.         term.setCursorPos(39,7)
  978.         print ("Button: ", buttonPad5)
  979.            
  980.  
  981.  
  982. --------------------- SCREEN / FLOOR 4 ---------------------
  983.  
  984.  
  985.         term.setCursorPos(4,8)
  986.         print "Floor 4:"
  987.  
  988.             if token4 == 0 then
  989.                 term.setCursorPos(13,8)
  990.                 print "STANDBY"
  991.             end
  992.             if token4 == 1 then
  993.                 term.setCursorPos(13,8)
  994.                 print "READY "
  995.             end
  996.             if token4 == 2 then
  997.                 term.setCursorPos(13,8)
  998.                 print "BUSY   "
  999.             end
  1000.             if token4 == 3 then
  1001.                 term.setCursorPos(13,8)
  1002.                 print "HOLD   "
  1003.             end
  1004.  
  1005.         term.setCursorPos(23,8)
  1006.         print "Sensor:"
  1007.  
  1008.         term.setCursorPos(39,8)
  1009.         print ("Button: ", buttonPad4)
  1010.  
  1011.  
  1012. --------------------- SCREEN / FLOOR 3 ---------------------
  1013.  
  1014.  
  1015.         term.setCursorPos(4,9)
  1016.         print "Floor 3:"
  1017.  
  1018.             if token3 == 0 then
  1019.                 term.setCursorPos(13,9)
  1020.                 print "STANDBY"
  1021.             end
  1022.             if token3 == 1 then
  1023.                 term.setCursorPos(13,9)
  1024.                 print "READY "
  1025.             end
  1026.             if token3 == 2 then
  1027.                 term.setCursorPos(13,9)
  1028.                 print "BUSY   "
  1029.             end
  1030.             if token3 == 3 then
  1031.                 term.setCursorPos(13,9)
  1032.                 print "HOLD   "
  1033.             end
  1034.  
  1035.         term.setCursorPos(23,9)
  1036.         print "Sensor:"
  1037.  
  1038.         term.setCursorPos(39,9)
  1039.         print ("Button: ", buttonPad3)
  1040.  
  1041.  
  1042.  
  1043. --------------------- SCREEN / FLOOR 2 ---------------------
  1044.  
  1045.  
  1046.         term.setCursorPos(4,10)
  1047.         print "Floor 2:"
  1048.  
  1049.             if token2 == 0 then
  1050.                 term.setCursorPos(13,10)
  1051.                 print "STANDBY"
  1052.             end
  1053.             if token2 == 1 then
  1054.                 term.setCursorPos(13,10)
  1055.                 print "READY "
  1056.             end
  1057.             if token2 == 2 then
  1058.                 term.setCursorPos(13,10)
  1059.                 print "BUSY   "
  1060.             end
  1061.             if token2 == 3 then
  1062.                 term.setCursorPos(13,10)
  1063.                 print "HOLD   "
  1064.             end
  1065.  
  1066.         term.setCursorPos(23,10)
  1067.         print "Sensor:"
  1068.  
  1069.         term.setCursorPos(39,10)
  1070.         print ("Button: ", buttonPad2)
  1071.  
  1072.  
  1073.  
  1074. --------------------- SCREEN / FLOOR 1 ---------------------
  1075.  
  1076.  
  1077.         term.setCursorPos(4,11)
  1078.         print "Floor 1:"
  1079.  
  1080.             if token1 == 0 then
  1081.                 term.setCursorPos(13,11)
  1082.                 print "STANDBY"
  1083.             end
  1084.             if token1 == 1 then
  1085.                 term.setCursorPos(13,11)
  1086.                 print "READY "
  1087.             end
  1088.             if token1 == 2 then
  1089.                 term.setCursorPos(13,11)
  1090.                 print "BUSY   "
  1091.             end
  1092.             if token1 == 3 then
  1093.                 term.setCursorPos(13,11)
  1094.                 print "HOLD   "
  1095.             end
  1096.  
  1097.         term.setCursorPos(23,11)
  1098.         print "Sensor:"
  1099.  
  1100.         term.setCursorPos(39,11)
  1101.         print ("Button: ", buttonPad1)
  1102.            
  1103.     end
  1104. end
  1105.  
  1106.  
  1107.  
  1108.  
  1109.  
  1110.  
  1111.  
  1112. --------------------- BUTTON COMMANDS ---------------------
  1113.  
  1114.  
  1115.  
  1116.  
  1117.  
  1118.  
  1119. ---------------- PHASE 1 BUTTON COMMANDS / FLOOR 1 ----------------
  1120.  
  1121.  
  1122.  
  1123.  
  1124.  
  1125.  
  1126.  
  1127.  
  1128.  
  1129.  
  1130. function killAll()
  1131.     redstone.setBundledOutput(cablePort1, 0)
  1132. end
  1133.    
  1134.  
  1135.  
  1136.  
  1137.  
  1138.  
  1139.  
  1140.  
  1141.  
  1142.  
  1143.  
  1144.  
  1145. function button7send()
  1146.  
  1147.     if sensor07 == false then
  1148.  
  1149.         token1 = 3  --  <---- - Tells the client 0=Standby 1=Ready 2=Busy 3=Hold
  1150.         token2 = 3
  1151.         token3 = 3
  1152.         token4 = 3
  1153.         token5 = 3
  1154.         token6 = 3
  1155.         token7 = 2
  1156.  
  1157.         term.clearLine()
  1158.         term.setCursorPos(1,16)
  1159.         print "Dispatching Elevator Cart to Floor 7"
  1160.         redstone.setBundledOutput(cablePort1, 0)
  1161.         sleep(.5)
  1162.         redstone.setBundledOutput(cablePort1, colors.orange+colors.red)
  1163.         sleep(.5)
  1164.         redstone.setBundledOutput(cablePort1, colors.orange)
  1165.         killfloor7()
  1166.     end
  1167.  
  1168.  
  1169.     if sensor07 == true then
  1170.  
  1171.         token1 = 3  --  <---- - Tells the client 0=Standby 1=Ready 2=Busy 3=Hold
  1172.         token2 = 3
  1173.         token3 = 3
  1174.         token4 = 3
  1175.         token5 = 3
  1176.         token6 = 3
  1177.         token7 = 2
  1178.  
  1179.         killfloor7()
  1180.     end
  1181. end
  1182.  
  1183.  
  1184.  
  1185.  
  1186.  
  1187. function button6send()
  1188.  
  1189.     if sensor06 == false then
  1190.  
  1191.         token1 = 3  --  <---- - Tells the client 0=Standby 1=Ready 2=Busy 3=Hold
  1192.         token2 = 3
  1193.         token3 = 3
  1194.         token4 = 3
  1195.         token5 = 3
  1196.         token6 = 2
  1197.         token7 = 3
  1198.  
  1199.         term.clearLine()
  1200.         term.setCursorPos(1,16)
  1201.         print "Dispatching Elevator Cart to Floor 6"
  1202.         redstone.setBundledOutput(cablePort1, 0)
  1203.         sleep(.5)
  1204.         redstone.setBundledOutput(cablePort1, colors.lightBlue+colors.red)
  1205.         sleep(.5)
  1206.         redstone.setBundledOutput(cablePort1, colors.lightBlue)
  1207.         killfloor6()
  1208.     end
  1209.  
  1210.  
  1211.     if sensor06 == true then
  1212.  
  1213.         token1 = 3  --  <---- - Tells the client 0=Standby 1=Ready 2=Busy 3=Hold
  1214.         token2 = 3
  1215.         token3 = 3
  1216.         token4 = 3
  1217.         token5 = 3
  1218.         token6 = 2
  1219.         token7 = 3
  1220.  
  1221.         killfloor6()
  1222.     end
  1223. end
  1224.  
  1225.  
  1226.  
  1227.  
  1228.  
  1229. function button5send()
  1230.  
  1231.     if sensor05 == false then
  1232.  
  1233.         token1 = 3  --  <---- - Tells the client 0=Standby 1=Ready 2=Busy 3=Hold
  1234.         token2 = 3
  1235.         token3 = 3
  1236.         token4 = 3
  1237.         token5 = 2
  1238.         token6 = 3
  1239.         token7 = 3
  1240.  
  1241.         term.clearLine()
  1242.         term.setCursorPos(1,16)
  1243.         print "Dispatching Elevator Cart to Floor 5"
  1244.         redstone.setBundledOutput(cablePort1, 0)
  1245.         sleep(.5)
  1246.         redstone.setBundledOutput(cablePort1, colors.lime+colors.red)
  1247.         sleep(.5)
  1248.         redstone.setBundledOutput(cablePort1, colors.lime)
  1249.         killfloor5()
  1250.     end
  1251.  
  1252.  
  1253.     if sensor05 == true then
  1254.  
  1255.         token1 = 3  --  <---- - Tells the client 0=Standby 1=Ready 2=Busy 3=Hold
  1256.         token2 = 3
  1257.         token3 = 3
  1258.         token4 = 3
  1259.         token5 = 2
  1260.         token6 = 3
  1261.         token7 = 3
  1262.  
  1263.         killfloor5()
  1264.     end
  1265. end
  1266.  
  1267.  
  1268.  
  1269.  
  1270.  
  1271. function button4send()
  1272.  
  1273.     if sensor04 == false then
  1274.  
  1275.         token1 = 3  --  <---- - Tells the client 0=Standby 1=Ready 2=Busy 3=Hold
  1276.         token2 = 3
  1277.         token3 = 3
  1278.         token4 = 2
  1279.         token5 = 3
  1280.         token6 = 3
  1281.         token7 = 3
  1282.  
  1283.         term.clearLine()
  1284.         term.setCursorPos(1,16)
  1285.         print "Dispatching Elevator Cart to Floor 4"
  1286.         redstone.setBundledOutput(cablePort1, 0)
  1287.         sleep(.5)
  1288.         redstone.setBundledOutput(cablePort1, colors.gray+colors.red)
  1289.         sleep(.5)
  1290.         redstone.setBundledOutput(cablePort1, colors.gray)
  1291.         killfloor4()
  1292.     end
  1293.  
  1294.  
  1295.     if sensor04 == true then
  1296.  
  1297.         token1 = 3  --  <---- - Tells the client 0=Standby 1=Ready 2=Busy 3=Hold
  1298.         token2 = 3
  1299.         token3 = 3
  1300.         token4 = 2
  1301.         token5 = 3
  1302.         token6 = 3
  1303.         token7 = 3
  1304.  
  1305.         killfloor4()
  1306.     end
  1307. end
  1308.  
  1309.  
  1310.  
  1311.  
  1312.  
  1313. function button3send()
  1314.  
  1315.     if sensor03 == false then
  1316.  
  1317.         token1 = 3  --  <---- - Tells the client 0=Standby 1=Ready 2=Busy 3=Hold
  1318.         token2 = 3
  1319.         token3 = 2
  1320.         token4 = 3
  1321.         token5 = 3
  1322.         token6 = 3
  1323.         token7 = 3
  1324.  
  1325.         term.clearLine()
  1326.         term.setCursorPos(1,16)
  1327.         print "Dispatching Elevator Cart to Floor 3"
  1328.         redstone.setBundledOutput(cablePort1, 0)
  1329.         sleep(.5)
  1330.         redstone.setBundledOutput(cablePort1, colors.cyan+colors.red)
  1331.         sleep(.5)
  1332.         redstone.setBundledOutput(cablePort1, colors.cyan)
  1333.         killfloor3()
  1334.     end
  1335.  
  1336.  
  1337.     if sensor03 == true then
  1338.  
  1339.         token1 = 3  --  <---- - Tells the client 0=Standby 1=Ready 2=Busy 3=Hold
  1340.         token2 = 3
  1341.         token3 = 2
  1342.         token4 = 3
  1343.         token5 = 3
  1344.         token6 = 3
  1345.         token7 = 3
  1346.  
  1347.         killfloor3()
  1348.     end
  1349. end
  1350.  
  1351.  
  1352.  
  1353.  
  1354.  
  1355. function button2send()
  1356.  
  1357.     if sensor02 == false then
  1358.  
  1359.         token1 = 3  --  <---- - Tells the client 0=Standby 1=Ready 2=Busy 3=Hold
  1360.         token2 = 2
  1361.         token3 = 3
  1362.         token4 = 3
  1363.         token5 = 3
  1364.         token6 = 3
  1365.         token7 = 3
  1366.  
  1367.         term.clearLine()
  1368.         term.setCursorPos(1,16)
  1369.         print "Dispatching Elevator Cart to Floor 2"
  1370.         redstone.setBundledOutput(cablePort1, 0)
  1371.         sleep(.5)
  1372.         redstone.setBundledOutput(cablePort1, colors.blue+colors.red)
  1373.         sleep(.5)
  1374.         redstone.setBundledOutput(cablePort1, colors.blue)
  1375.         killfloor2()
  1376.     end
  1377.  
  1378.  
  1379.     if sensor02 == true then
  1380.  
  1381.         token1 = 3  --  <---- - Tells the client 0=Standby 1=Ready 2=Busy 3=Hold
  1382.         token2 = 2
  1383.         token3 = 3
  1384.         token4 = 3
  1385.         token5 = 3
  1386.         token6 = 3
  1387.         token7 = 3
  1388.  
  1389.         killfloor2()
  1390.     end
  1391. end
  1392.  
  1393.  
  1394.  
  1395.  
  1396.  
  1397. function button1send()
  1398.  
  1399.     if sensor01 == false then
  1400.  
  1401.         token1 = 2  --  <---- - Tells the client 0=Standby 1=Ready 2=Busy 3=Hold
  1402.         token2 = 3
  1403.         token3 = 3
  1404.         token4 = 3
  1405.         token5 = 3
  1406.         token6 = 3
  1407.         token7 = 3
  1408.  
  1409.         term.clearLine()
  1410.         term.setCursorPos(1,16)
  1411.         print "Dispatching Elevator Cart to Floor 1"
  1412.         redstone.setBundledOutput(cablePort1, 0)
  1413.         sleep(.5)
  1414.         redstone.setBundledOutput(cablePort1, colors.red)
  1415.         sleep(.5)
  1416.         redstone.setBundledOutput(cablePort1, 0)
  1417.         killfloor1()
  1418.  
  1419.     end
  1420.  
  1421.  
  1422.     if sensor01 == true then
  1423.  
  1424.         token1 = 2  --  <---- - Tells the client 0=Standby 1=Ready 2=Busy 3=Hold
  1425.         token2 = 3
  1426.         token3 = 3
  1427.         token4 = 3
  1428.         token5 = 3
  1429.         token6 = 3
  1430.         token7 = 3
  1431.  
  1432.         killfloor1()
  1433.     end
  1434. end
  1435.  
  1436.  
  1437.  
  1438.  
  1439.  
  1440.  
  1441.  
  1442.  
  1443.  
  1444.  
  1445.  
  1446.  
  1447.  
  1448.  
  1449.  
  1450.  
  1451.  
  1452.  
  1453.  
  1454.  
  1455.  
  1456.  
  1457.  
  1458. ---------------- PHASE 2 BUTTON COMMANDS ----------------
  1459.  
  1460.  
  1461.  
  1462.  
  1463. function buttonwait7()
  1464.  
  1465.  
  1466.     token1 = 3  --  <---- - Tells the client 0=Standby 1=Ready 2=Busy 3=Hold
  1467.     token2 = 3
  1468.     token3 = 3
  1469.     token4 = 3
  1470.     token5 = 3
  1471.     token6 = 3
  1472.     token7 = 1
  1473.                                                 -- <---------------- PHASE 2 FLOOR 7 ----------------
  1474.  
  1475.         sleep(0)
  1476.  
  1477.             if clientID == 7 then
  1478.  
  1479.                 if buttonPad7 == 6 then
  1480.                     sleep(1)
  1481.                     term.setCursorPos(1,16)
  1482.                     print "Floor 7 to 6: - [SYSTEM ARMED & LOCKED]"
  1483.                     redstone.setBundledOutput(cablePort1, colors.lightBlue)
  1484.                     KillAfterWait6()
  1485.                     buttonPad7 = 0
  1486.                     clientID = 0
  1487.                 end
  1488.             end
  1489.  
  1490.             if clientID == 7 then
  1491.  
  1492.                 if buttonPad7 == 5 then
  1493.                     sleep(1)
  1494.                     term.setCursorPos(1,16)
  1495.                     print "Floor 7 to 5: - [SYSTEM ARMED & LOCKED]"
  1496.                     redstone.setBundledOutput(cablePort1, colors.lime)
  1497.                     KillAfterWait5()
  1498.                     buttonPad7 = 0
  1499.                     clientID = 0
  1500.                 end
  1501.             end
  1502.  
  1503.             if clientID == 7 then
  1504.  
  1505.                 if buttonPad7 == 4 then
  1506.                     sleep(1)
  1507.                     term.setCursorPos(1,16)
  1508.                     print "Floor 7 to 4: - [SYSTEM ARMED & LOCKED]"
  1509.                     redstone.setBundledOutput(cablePort1, colors.gray)
  1510.                     KillAfterWait4()
  1511.                     buttonPad7 = 0
  1512.                     clientID = 0
  1513.                 end
  1514.             end
  1515.  
  1516.             if clientID == 7 then
  1517.  
  1518.                 if buttonPad7 == 3 then
  1519.                     sleep(1)
  1520.                     term.setCursorPos(1,16)
  1521.                     print "Floor 7 to 3: - [SYSTEM ARMED & LOCKED]"
  1522.                     redstone.setBundledOutput(cablePort1, colors.cyan)
  1523.                     KillAfterWait3()
  1524.                     buttonPad7 = 0
  1525.                     clientID = 0
  1526.                 end
  1527.             end
  1528.  
  1529.             if clientID == 7 then
  1530.  
  1531.                 if buttonPad7 == 2 then
  1532.                     sleep(1)
  1533.                     term.setCursorPos(1,16)
  1534.                     print "Floor 7 to 2: - [SYSTEM ARMED & LOCKED]"
  1535.                     redstone.setBundledOutput(cablePort1, colors.blue)
  1536.                     KillAfterWait2()
  1537.                     buttonPad7 = 0
  1538.                     clientID = 0
  1539.                 end
  1540.             end
  1541.  
  1542.             if clientID == 7 then
  1543.  
  1544.                 if buttonPad7 == 1 then
  1545.                     sleep(1)
  1546.                     term.setCursorPos(1,16)
  1547.                     print "Floor 7 to 1: - [SYSTEM ARMED & LOCKED]"
  1548.                     redstone.setBundledOutput(cablePort1, 0)
  1549.                     KillAfterWait1()
  1550.                     buttonPad7 = 0
  1551.                     clientID = 0
  1552.                 end
  1553.             end
  1554.    
  1555. end
  1556.    
  1557.  
  1558.  
  1559.  
  1560.  
  1561.  
  1562.  
  1563.  
  1564. function buttonwait6()                                      -- <---------------- PHASE 2 FLOOR 6 ----------------
  1565.  
  1566.     token1 = 3  --  <---- - Tells the client 0=Standby 1=Ready 2=Busy 3=Hold
  1567.     token2 = 3
  1568.     token3 = 3
  1569.     token4 = 3
  1570.     token5 = 3
  1571.     token6 = 1
  1572.     token7 = 3
  1573.  
  1574.         sleep(0)
  1575.  
  1576.             if clientID == 6 then
  1577.  
  1578.                 if buttonPad6 == 7 then
  1579.                     sleep(1)
  1580.                     term.setCursorPos(1,16)
  1581.                     print "Floor 6 to 7: - [SYSTEM ARMED & LOCKED]"
  1582.                     redstone.setBundledOutput(cablePort1, colors.orange)
  1583.                     KillAfterWait7()
  1584.                     buttonPad6 = 0
  1585.                     clientID = 0                   
  1586.                 end
  1587.             end
  1588.  
  1589.             if clientID == 6 then
  1590.  
  1591.                 if buttonPad6 == 5 then
  1592.                     sleep(1)
  1593.                     term.setCursorPos(1,16)
  1594.                     print "Floor 6 to 5: - [SYSTEM ARMED & LOCKED]"
  1595.                     redstone.setBundledOutput(cablePort1, colors.lime)
  1596.                     KillAfterWait5()
  1597.                     buttonPad6 = 0
  1598.                     clientID = 0
  1599.                 end
  1600.             end
  1601.  
  1602.             if clientID == 6 then
  1603.  
  1604.                 if buttonPad6 == 4 then
  1605.                     sleep(1)
  1606.                     term.setCursorPos(1,16)
  1607.                     print "Floor 6 to 4: - [SYSTEM ARMED & LOCKED]"
  1608.                     redstone.setBundledOutput(cablePort1, colors.gray)
  1609.                     KillAfterWait4()
  1610.                     buttonPad6 = 0
  1611.                     clientID = 0
  1612.                 end
  1613.             end
  1614.  
  1615.             if clientID == 6 then
  1616.  
  1617.                 if buttonPad6 == 3 then
  1618.                     sleep(1)
  1619.                     term.setCursorPos(1,16)
  1620.                     print "Floor 6 to 3: - [SYSTEM ARMED & LOCKED]"
  1621.                     redstone.setBundledOutput(cablePort1, colors.cyan)
  1622.                     KillAfterWait3()
  1623.                     buttonPad6 = 0
  1624.                     clientID = 0
  1625.                 end
  1626.             end
  1627.  
  1628.             if clientID == 6 then
  1629.  
  1630.                 if buttonPad6 == 2 then
  1631.                     sleep(1)
  1632.                     term.setCursorPos(1,16)
  1633.                     print "Floor 6 to 2: - [SYSTEM ARMED & LOCKED]"
  1634.                     redstone.setBundledOutput(cablePort1, colors.blue)
  1635.                     KillAfterWait2()
  1636.                     buttonPad6 = 0
  1637.                     clientID = 0
  1638.                 end
  1639.             end
  1640.  
  1641.             if clientID == 6 then
  1642.  
  1643.                 if buttonPad6 == 1 then
  1644.                     sleep(1)
  1645.                     term.setCursorPos(1,16)
  1646.                     print "Floor 6 to 1: - [SYSTEM ARMED & LOCKED]"
  1647.                     redstone.setBundledOutput(cablePort1, 0)
  1648.                     KillAfterWait1()
  1649.                     buttonPad6 = 0
  1650.                     clientID = 0
  1651.                 end
  1652.             end
  1653.    
  1654. end
  1655.  
  1656.  
  1657.  
  1658.  
  1659. function buttonwait5()                                      -- <---------------- PHASE 2 FLOOR 5 ----------------
  1660.  
  1661.     token1 = 3  --  <---- - Tells the client 0=Standby 1=Ready 2=Busy 3=Hold
  1662.     token2 = 3
  1663.     token3 = 3
  1664.     token4 = 3
  1665.     token5 = 1
  1666.     token6 = 3
  1667.     token7 = 3
  1668.                                                    
  1669.         sleep(0)
  1670.  
  1671.             if clientID == 5 then
  1672.  
  1673.                 if buttonPad5 == 7 then
  1674.                     sleep(1)
  1675.                     term.setCursorPos(1,16)
  1676.                     print "Floor 5 to 7: - [SYSTEM ARMED & LOCKED]"
  1677.                     redstone.setBundledOutput(cablePort1, colors.orange)
  1678.                     KillAfterWait7()
  1679.                     buttonPad5 = 0
  1680.                     clientID = 0
  1681.                 end
  1682.             end
  1683.  
  1684.             if clientID == 5 then
  1685.  
  1686.                 if buttonPad5 == 6 then
  1687.                     sleep(1)
  1688.                     term.setCursorPos(1,16)
  1689.                     print "Floor 5 to 6: - [SYSTEM ARMED & LOCKED]"
  1690.                     redstone.setBundledOutput(cablePort1, colors.lightBlue)
  1691.                     KillAfterWait6()
  1692.                     buttonPad5 = 0
  1693.                     clientID = 0
  1694.                 end
  1695.             end
  1696.  
  1697.             if clientID == 5 then
  1698.  
  1699.                 if buttonPad5 == 4 then
  1700.                     sleep(1)
  1701.                     term.setCursorPos(1,16)
  1702.                     print "Floor 5 to 4: - [SYSTEM ARMED & LOCKED]"
  1703.                     redstone.setBundledOutput(cablePort1, colors.gray)
  1704.                     KillAfterWait4()
  1705.                     buttonPad5 = 0
  1706.                     clientID = 0
  1707.                 end
  1708.             end
  1709.  
  1710.             if clientID == 5 then
  1711.  
  1712.                 if buttonPad5 == 3 then
  1713.                     sleep(1)
  1714.                     term.setCursorPos(1,16)
  1715.                     print "Floor 5 to 3: - [SYSTEM ARMED & LOCKED]"
  1716.                     redstone.setBundledOutput(cablePort1, colors.cyan)
  1717.                     KillAfterWait3()
  1718.                     buttonPad5 = 0
  1719.                     clientID = 0
  1720.                 end
  1721.             end
  1722.  
  1723.             if clientID == 5 then
  1724.  
  1725.                 if buttonPad5 == 2 then
  1726.                     sleep(1)
  1727.                     term.setCursorPos(1,16)
  1728.                     print "Floor 5 to 2: - [SYSTEM ARMED & LOCKED]"
  1729.                     redstone.setBundledOutput(cablePort1, colors.blue)
  1730.                     KillAfterWait2()
  1731.                     buttonPad5 = 0
  1732.                     clientID = 0
  1733.                 end
  1734.             end
  1735.  
  1736.             if clientID == 5 then
  1737.  
  1738.                 if buttonPad5 == 1 then
  1739.                     sleep(1)
  1740.                     term.setCursorPos(1,16)
  1741.                     print "Floor 5 to 1: - [SYSTEM ARMED & LOCKED]"
  1742.                     redstone.setBundledOutput(cablePort1, 0)
  1743.                     KillAfterWait1()
  1744.                     buttonPad5 = 0
  1745.                     clientID = 0
  1746.                 end
  1747.             end
  1748.    
  1749. end
  1750.  
  1751.  
  1752.  
  1753.  
  1754.  
  1755.  
  1756.  
  1757. function buttonwait4()                                      -- <---------------- PHASE 2 FLOOR 4 ----------------
  1758.  
  1759.     token1 = 3  --  <---- - Tells the client 0=Standby 1=Ready 2=Busy 3=Hold
  1760.     token2 = 3
  1761.     token3 = 3
  1762.     token4 = 1
  1763.     token5 = 3
  1764.     token6 = 3
  1765.     token7 = 3
  1766.        
  1767.         sleep(0)
  1768.  
  1769.             if clientID == 4 then
  1770.  
  1771.                 if buttonPad4 == 7 then
  1772.                     sleep(1)
  1773.                     term.setCursorPos(1,16)
  1774.                     print "Floor 4 to 7: - [SYSTEM ARMED & LOCKED]"
  1775.                     redstone.setBundledOutput(cablePort1, colors.orange)
  1776.                     KillAfterWait7()
  1777.                     buttonPad4 = 0
  1778.                     clientID = 0
  1779.                 end
  1780.             end
  1781.  
  1782.             if clientID == 4 then
  1783.  
  1784.                 if buttonPad4 == 6 then
  1785.                     sleep(1)
  1786.                     term.setCursorPos(1,16)
  1787.                     print "Floor 4 to 6: - [SYSTEM ARMED & LOCKED]"
  1788.                     redstone.setBundledOutput(cablePort1, colors.lightBlue)
  1789.                     KillAfterWait6()
  1790.                     buttonPad4 = 0
  1791.                     clientID = 0
  1792.                 end
  1793.             end
  1794.  
  1795.             if clientID == 4 then
  1796.  
  1797.                 if buttonPad4 == 5 then
  1798.                     sleep(1)
  1799.                     term.setCursorPos(1,16)
  1800.                     print "Floor 4 to 5: - [SYSTEM ARMED & LOCKED]"
  1801.                     redstone.setBundledOutput(cablePort1, colors.lime)
  1802.                     KillAfterWait5()
  1803.                     buttonPad4 = 0
  1804.                     clientID = 0
  1805.                 end
  1806.             end
  1807.  
  1808.             if clientID == 4 then
  1809.  
  1810.                 if buttonPad4 == 3 then
  1811.                     sleep(1)
  1812.                     term.setCursorPos(1,16)
  1813.                     print "Floor 4 to 3: - [SYSTEM ARMED & LOCKED]"
  1814.                     redstone.setBundledOutput(cablePort1, colors.cyan)
  1815.                     KillAfterWait3()
  1816.                     buttonPad4 = 0
  1817.                 end
  1818.             end
  1819.  
  1820.             if clientID == 4 then
  1821.  
  1822.                 if buttonPad4 == 2 then
  1823.                     sleep(1)
  1824.                     term.setCursorPos(1,16)
  1825.                     print "Floor 4 to 2: - [SYSTEM ARMED & LOCKED]"
  1826.                     redstone.setBundledOutput(cablePort1, colors.blue)
  1827.                     KillAfterWait2()
  1828.                     buttonPad4 = 0
  1829.                     clientID = 0
  1830.                 end
  1831.             end
  1832.  
  1833.             if clientID == 4 then
  1834.  
  1835.                 if buttonPad4 == 1 then
  1836.                     sleep(1)
  1837.                     term.setCursorPos(1,16)
  1838.                     print "Floor 4 to 1: - [SYSTEM ARMED & LOCKED]"
  1839.                     redstone.setBundledOutput(cablePort1, 0)
  1840.                     KillAfterWait1()
  1841.                     buttonPad4 = 0
  1842.                     clientID = 0
  1843.                 end
  1844.             end
  1845.    
  1846. end
  1847.  
  1848.  
  1849.  
  1850.  
  1851. function buttonwait3()                                      -- <---------------- PHASE 2 FLOOR 3 ----------------
  1852.  
  1853.     token1 = 3  --  <---- - Tells the client 0=Standby 1=Ready 2=Busy 3=Hold
  1854.     token2 = 3
  1855.     token3 = 1
  1856.     token4 = 3
  1857.     token5 = 3
  1858.     token6 = 3
  1859.     token7 = 3
  1860.  
  1861.         sleep(0)
  1862.  
  1863.             if clientID == 3 then
  1864.  
  1865.                 if buttonPad3 == 7 then
  1866.                     sleep(1)
  1867.                     term.setCursorPos(1,16)
  1868.                     print "Floor 3 to 7: - [SYSTEM ARMED & LOCKED]"
  1869.                     redstone.setBundledOutput(cablePort1, colors.orange)
  1870.                     KillAfterWait7()
  1871.                     buttonPad3 = 0
  1872.                     clientID = 0
  1873.                 end
  1874.             end
  1875.  
  1876.             if clientID == 3 then
  1877.  
  1878.                 if buttonPad3 == 6 then
  1879.                     sleep(1)
  1880.                     term.setCursorPos(1,16)
  1881.                     print "Floor 3 to 6: - [SYSTEM ARMED & LOCKED]"
  1882.                     redstone.setBundledOutput(cablePort1, colors.lightBlue)
  1883.                     KillAfterWait6()
  1884.                     buttonPad3 = 0
  1885.                     clientID = 0
  1886.                 end
  1887.             end
  1888.  
  1889.             if clientID == 3 then
  1890.  
  1891.                 if buttonPad3 == 5 then
  1892.                     sleep(1)
  1893.                     term.setCursorPos(1,16)
  1894.                     print "Floor 3 to 5: - [SYSTEM ARMED & LOCKED]"
  1895.                     redstone.setBundledOutput(cablePort1, colors.lime)
  1896.                     KillAfterWait5()
  1897.                     buttonPad3 = 0
  1898.                     clientID = 0
  1899.                 end
  1900.             end
  1901.  
  1902.             if clientID == 3 then
  1903.  
  1904.                 if buttonPad3 == 4 then
  1905.                     sleep(1)
  1906.                     term.setCursorPos(1,16)
  1907.                     print "Floor 3 to 4: - [SYSTEM ARMED & LOCKED]"
  1908.                     redstone.setBundledOutput(cablePort1, colors.gray)
  1909.                     KillAfterWait4()
  1910.                     buttonPad3 = 0
  1911.                     clientID = 0
  1912.                 end
  1913.             end
  1914.  
  1915.             if clientID == 3 then
  1916.  
  1917.                 if buttonPad3 == 2 then
  1918.                     sleep(1)
  1919.                     term.setCursorPos(1,16)
  1920.                     print "Floor 3 to 2: - [SYSTEM ARMED & LOCKED]"
  1921.                     redstone.setBundledOutput(cablePort1, colors.blue)
  1922.                     KillAfterWait2()
  1923.                     buttonPad3 = 0
  1924.                     clientID = 0
  1925.                 end
  1926.             end
  1927.  
  1928.             if clientID == 3 then
  1929.  
  1930.                 if buttonPad3 == 1 then
  1931.                     sleep(1)
  1932.                     term.setCursorPos(1,16)
  1933.                     print "Floor 3 to 1: - [SYSTEM ARMED & LOCKED]"
  1934.                     redstone.setBundledOutput(cablePort1, 0)
  1935.                     KillAfterWait1()
  1936.                     buttonPad3 = 0
  1937.                     clientID = 0
  1938.                 end
  1939.             end
  1940.    
  1941. end
  1942.  
  1943.  
  1944.  
  1945.  
  1946.  
  1947. function buttonwait2()                                      -- <---------------- PHASE 2 FLOOR 2 ----------------
  1948.  
  1949.     token1 = 3  --  <---- - Tells the client 0=Standby 1=Ready 2=Busy 3=Hold
  1950.     token2 = 1
  1951.     token3 = 3
  1952.     token4 = 3
  1953.     token5 = 3
  1954.     token6 = 3
  1955.     token7 = 3
  1956.  
  1957.         sleep(0)
  1958.  
  1959.             if clientID == 2 then
  1960.  
  1961.                 if buttonPad2 == 7 then
  1962.                     sleep(1)
  1963.                     term.setCursorPos(1,16)
  1964.                     print "Floor 2 to 7: - [SYSTEM ARMED & LOCKED]"
  1965.                     redstone.setBundledOutput(cablePort1, colors.orange)
  1966.                     KillAfterWait7()
  1967.                     buttonPad2 = 0
  1968.                     clientID = 0
  1969.                 end
  1970.             end
  1971.  
  1972.             if clientID == 2 then
  1973.  
  1974.                 if buttonPad2 == 6 then
  1975.                     sleep(1)
  1976.                     term.setCursorPos(1,16)
  1977.                     print "Floor 2 to 6: - [SYSTEM ARMED & LOCKED]"
  1978.                     redstone.setBundledOutput(cablePort1, colors.lightBlue)
  1979.                     KillAfterWait6()
  1980.                     buttonPad2 = 0
  1981.                     clientID = 0
  1982.                 end
  1983.             end
  1984.  
  1985.             if clientID == 2 then
  1986.  
  1987.                 if buttonPad2 == 5 then
  1988.                     sleep(1)
  1989.                     term.setCursorPos(1,16)
  1990.                     print "Floor 2 to 5: - [SYSTEM ARMED & LOCKED]"
  1991.                     redstone.setBundledOutput(cablePort1, colors.lime)
  1992.                     KillAfterWait5()
  1993.                     buttonPad2 = 0
  1994.                     clientID = 0
  1995.                 end
  1996.             end
  1997.  
  1998.             if clientID == 2 then
  1999.  
  2000.                 if buttonPad2 == 4 then
  2001.                     sleep(1)
  2002.                     term.setCursorPos(1,16)
  2003.                     print "Floor 2 to 4: - [SYSTEM ARMED & LOCKED]"
  2004.                     redstone.setBundledOutput(cablePort1, colors.gray)
  2005.                     KillAfterWait4()
  2006.                     buttonPad2 = 0
  2007.                     clientID = 0
  2008.                 end
  2009.             end
  2010.  
  2011.             if clientID == 2 then
  2012.  
  2013.                 if buttonPad2 == 3 then
  2014.                     sleep(1)
  2015.                     term.setCursorPos(1,16)
  2016.                     print "Floor 2 to 3: - [SYSTEM ARMED & LOCKED]"
  2017.                     redstone.setBundledOutput(cablePort1, colors.cyan)
  2018.                     KillAfterWait3()
  2019.                     buttonPad2 = 0
  2020.                     clientID = 0
  2021.                 end
  2022.             end
  2023.  
  2024.             if clientID == 2 then
  2025.  
  2026.                 if buttonPad2 == 1 then
  2027.                     sleep(1)
  2028.                     term.setCursorPos(1,16)
  2029.                     print "Floor 2 to 1: - [SYSTEM ARMED & LOCKED]"
  2030.                     redstone.setBundledOutput(cablePort1, 0)
  2031.                     KillAfterWait1()
  2032.                     buttonPad2 = 0
  2033.                     clientID = 0
  2034.                 end
  2035.             end
  2036.    
  2037. end
  2038.  
  2039.  
  2040.  
  2041. function buttonwait1()                                      -- <---------------- PHASE 2 FLOOR 1 ----------------
  2042.  
  2043.     token1 = 1  --  <---- - Tells the client 0=Standby 1=Ready 2=Busy 3=Hold
  2044.     token2 = 3
  2045.     token3 = 3
  2046.     token4 = 3
  2047.     token5 = 3
  2048.     token6 = 3
  2049.     token7 = 3
  2050.  
  2051.         sleep(0)
  2052.             if clientID == 1 then
  2053.  
  2054.                 if buttonPad1 == 7 then
  2055.                     sleep(1)
  2056.                     term.setCursorPos(1,16)
  2057.                     print "Floor 1 to 7: - [SYSTEM ARMED & LOCKED]"
  2058.                     redstone.setBundledOutput(cablePort1, colors.orange)
  2059.                     KillAfterWait7()
  2060.                     buttonPad1 = 0
  2061.                     clientID = 0
  2062.                 end
  2063.             end
  2064.  
  2065.             if clientID == 1 then
  2066.  
  2067.                 if buttonPad1 == 6 then
  2068.                     sleep(1)
  2069.                     term.setCursorPos(1,16)
  2070.                     print "Floor 1 to 6: - [SYSTEM ARMED & LOCKED]"
  2071.                     redstone.setBundledOutput(cablePort1, colors.lightBlue)
  2072.                     KillAfterWait6()
  2073.                     buttonPad1 = 0
  2074.                     clientID = 0
  2075.                 end
  2076.             end
  2077.  
  2078.             if clientID == 1 then
  2079.  
  2080.                 if buttonPad1 == 5 then
  2081.                     sleep(1)
  2082.                     term.setCursorPos(1,16)
  2083.                     print "Floor 1 to 5: - [SYSTEM ARMED & LOCKED]"
  2084.                     redstone.setBundledOutput(cablePort1, colors.lime)
  2085.                     KillAfterWait5()
  2086.                     buttonPad1 = 0
  2087.                     clientID = 0
  2088.                 end
  2089.             end
  2090.  
  2091.             if clientID == 1 then
  2092.  
  2093.                 if buttonPad1 == 4 then
  2094.                     sleep(1)
  2095.                     term.setCursorPos(1,16)
  2096.                     print "Floor 1 to 4: - [SYSTEM ARMED & LOCKED]"
  2097.                     redstone.setBundledOutput(cablePort1, colors.gray)
  2098.                     KillAfterWait4()
  2099.                     buttonPad1 = 0
  2100.                     clientID = 0
  2101.                 end
  2102.             end
  2103.  
  2104.             if clientID == 1 then
  2105.  
  2106.                 if buttonPad1 == 3 then
  2107.                     sleep(1)
  2108.                     term.setCursorPos(1,16)
  2109.                     print "Floor 1 to 3: - [SYSTEM ARMED & LOCKED]"
  2110.                     redstone.setBundledOutput(cablePort1, colors.cyan)
  2111.                     KillAfterWait3()
  2112.                     buttonPad1 = 0
  2113.                     clientID = 0
  2114.                 end
  2115.             end
  2116.  
  2117.             if clientID == 1 then
  2118.  
  2119.                 if buttonPad1 == 2 then
  2120.                     sleep(1)
  2121.                     term.setCursorPos(1,16)
  2122.                     print "Floor 1 to 2: - [SYSTEM ARMED & LOCKED]"
  2123.                     redstone.setBundledOutput(cablePort1, colors.blue)
  2124.                     KillAfterWait2()
  2125.                     buttonPad1 = 0
  2126.                     clientID = 0
  2127.                 end
  2128.             end
  2129.  
  2130.    
  2131. end
  2132.  
  2133.  
  2134.  
  2135.  
  2136.  
  2137.  
  2138.  
  2139.  
  2140.  
  2141.  
  2142.  
  2143.  
  2144.  
  2145.  
  2146.  
  2147.  
  2148.  
  2149.  
  2150.  
  2151.  
  2152.  
  2153.  
  2154.  
  2155.  
  2156.  
  2157.  
  2158.  
  2159.  
  2160. function KillAfterWait1()
  2161.  
  2162.  
  2163.         while true do
  2164.         sleep(0)
  2165.  
  2166.             if cartSensorData[1] == true then
  2167.                 redstone.setBundledOutput(cablePort1, 0)
  2168.                 term.setCursorPos(1,16)
  2169.                 print "Elevator Status: Ready                 "
  2170.  
  2171.         token1 = 0  --  <---- - Tells the client 0=Standby 1=Ready 2=Busy 3=Hold
  2172.         token2 = 0
  2173.         token3 = 0
  2174.         token4 = 0
  2175.         token5 = 0
  2176.         token6 = 0
  2177.         token7 = 0
  2178.  
  2179.             break end
  2180.         end
  2181. end
  2182.  
  2183.  
  2184.  
  2185.  
  2186. function KillAfterWait2()
  2187.  
  2188.  
  2189.         while true do
  2190.         sleep(0)
  2191.  
  2192.             if cartSensorData[2] == true then
  2193.                 redstone.setBundledOutput(cablePort1, 0)
  2194.                 term.setCursorPos(1,16)
  2195.                 print "Elevator Status: Ready                 "
  2196.  
  2197.         token1 = 0  --  <---- - Tells the client 0=Standby 1=Ready 2=Busy 3=Hold
  2198.         token2 = 0
  2199.         token3 = 0
  2200.         token4 = 0
  2201.         token5 = 0
  2202.         token6 = 0
  2203.         token7 = 0
  2204.  
  2205.             break end
  2206.         end
  2207. end
  2208.  
  2209.  
  2210.  
  2211.  
  2212. function KillAfterWait3()
  2213.  
  2214.  
  2215.         while true do
  2216.         sleep(0)
  2217.  
  2218.             if cartSensorData[3] == true then
  2219.                 redstone.setBundledOutput(cablePort1, 0)
  2220.                 term.setCursorPos(1,16)
  2221.                 print "Elevator Status: Ready                 "
  2222.  
  2223.         token1 = 0  --  <---- - Tells the client 0=Standby 1=Ready 2=Busy 3=Hold
  2224.         token2 = 0
  2225.         token3 = 0
  2226.         token4 = 0
  2227.         token5 = 0
  2228.         token6 = 0
  2229.         token7 = 0
  2230.  
  2231.             break end
  2232.         end
  2233. end
  2234.  
  2235.  
  2236.  
  2237.  
  2238. function KillAfterWait4()
  2239.  
  2240.  
  2241.         while true do
  2242.         sleep(0)
  2243.  
  2244.             if cartSensorData[4] == true then
  2245.                 redstone.setBundledOutput(cablePort1, 0)
  2246.                 term.setCursorPos(1,16)
  2247.                 print "Elevator Status: Ready                 "
  2248.  
  2249.         token1 = 0  --  <---- - Tells the client 0=Standby 1=Ready 2=Busy 3=Hold
  2250.         token2 = 0
  2251.         token3 = 0
  2252.         token4 = 0
  2253.         token5 = 0
  2254.         token6 = 0
  2255.         token7 = 0
  2256.  
  2257.             break end
  2258.         end
  2259. end
  2260.  
  2261.  
  2262.  
  2263.  
  2264. function KillAfterWait5()
  2265.  
  2266.  
  2267.         while true do
  2268.         sleep(0)
  2269.  
  2270.             if cartSensorData[5] == true then
  2271.                 redstone.setBundledOutput(cablePort1, 0)
  2272.                 term.setCursorPos(1,16)
  2273.                 print "Elevator Status: Ready                 "
  2274.  
  2275.         token1 = 0  --  <---- - Tells the client 0=Standby 1=Ready 2=Busy 3=Hold
  2276.         token2 = 0
  2277.         token3 = 0
  2278.         token4 = 0
  2279.         token5 = 0
  2280.         token6 = 0
  2281.         token7 = 0
  2282.  
  2283.             break end
  2284.         end
  2285. end
  2286.  
  2287.  
  2288.  
  2289.  
  2290. function KillAfterWait6()
  2291.  
  2292.  
  2293.         while true do
  2294.         sleep(0)
  2295.  
  2296.             if cartSensorData[6] == true then
  2297.                 redstone.setBundledOutput(cablePort1, 0)
  2298.                 term.setCursorPos(1,16)
  2299.                 print "Elevator Status: Ready                 "
  2300.  
  2301.         token1 = 0  --  <---- - Tells the client 0=Standby 1=Ready 2=Busy 3=Hold
  2302.         token2 = 0
  2303.         token3 = 0
  2304.         token4 = 0
  2305.         token5 = 0
  2306.         token6 = 0
  2307.         token7 = 0
  2308.  
  2309.             break end
  2310.         end
  2311. end
  2312.  
  2313.  
  2314.  
  2315.  
  2316. function KillAfterWait7()
  2317.  
  2318.  
  2319.         while true do
  2320.         sleep(0)
  2321.  
  2322.             if cartSensorData[7] == true then
  2323.                 redstone.setBundledOutput(cablePort1, 0)
  2324.                 term.setCursorPos(1,16)
  2325.                 print "Elevator Status: Ready                 "
  2326.  
  2327.         token1 = 0  --  <---- - Tells the client 0=Standby 1=Ready 2=Busy 3=Hold
  2328.         token2 = 0
  2329.         token3 = 0
  2330.         token4 = 0
  2331.         token5 = 0
  2332.         token6 = 0
  2333.         token7 = 0
  2334.  
  2335.             break end
  2336.         end
  2337. end
  2338.  
  2339.  
  2340.  
  2341.  
  2342.  
  2343.  
  2344.  
  2345.  
  2346.  
  2347.  
  2348.  
  2349.  
  2350.  
  2351.  
  2352.  
  2353.  
  2354.  
  2355.  
  2356.  
  2357.  
  2358.  
  2359.  
  2360. ---------------- KILL FLOOR POWER COMMANDS ----------------
  2361.  
  2362. function killfloor1()
  2363.  
  2364.     while true do
  2365.     sleep(0)
  2366.  
  2367.         if cartSensorData[1] == true then
  2368.             killAll()
  2369.         break
  2370.         end
  2371.     end
  2372. end
  2373.  
  2374.  
  2375. function killfloor2()
  2376.  
  2377.     while true do
  2378.     sleep(0)
  2379.  
  2380.         if cartSensorData[2] == true then
  2381.             killAll()
  2382.         break
  2383.         end
  2384.     end
  2385. end
  2386.  
  2387.  
  2388.  
  2389. function killfloor3()
  2390.  
  2391.     while true do
  2392.     sleep(0)
  2393.  
  2394.         if cartSensorData[3] == true then
  2395.             killAll()
  2396.         break
  2397.         end
  2398.     end
  2399. end
  2400.  
  2401.  
  2402.  
  2403. function killfloor4()
  2404.  
  2405.     while true do
  2406.     sleep(0)
  2407.  
  2408.         if cartSensorData[4] == true then
  2409.             killAll()
  2410.         break
  2411.         end
  2412.     end
  2413. end
  2414.  
  2415.  
  2416.  
  2417. function killfloor5()
  2418.  
  2419.     while true do
  2420.     sleep(0)
  2421.  
  2422.         if cartSensorData[5] == true then
  2423.             killAll()
  2424.         break
  2425.         end
  2426.     end
  2427. end
  2428.  
  2429.  
  2430.  
  2431.  
  2432. function killfloor6()
  2433.  
  2434.     while true do
  2435.     sleep(0)
  2436.  
  2437.         if cartSensorData[6] == true then
  2438.             killAll()
  2439.         break
  2440.         end
  2441.     end
  2442. end
  2443.  
  2444.  
  2445.  
  2446. function killfloor7()
  2447.  
  2448.     while true do
  2449.     sleep(0)
  2450.  
  2451.         if cartSensorData[7] == true then
  2452.             killAll()
  2453.         break
  2454.         end
  2455.     end
  2456. end
  2457.  
  2458.  
  2459.  
  2460.  
  2461.  
  2462.  
  2463.  
  2464.  
  2465.  
  2466.  
  2467. -- SNIFFER
  2468.  
  2469. sniffer = function()
  2470.  
  2471.     while true do
  2472.     sleep(0)
  2473.  
  2474.         if (buttonPad1 == 2) or (buttonPad1 == 3) or (buttonPad1 == 4) or (buttonPad1 == 5) or (buttonPad1 == 6) or (buttonPad1 == 7) then
  2475.  
  2476.                 button1send()                   --  <------------------------- Dispatches CART to FLOOR [1] to pick up rider.
  2477.                 term.setCursorPos(1,16)
  2478.                 term.clearLine()
  2479. --              print "Elevator Cart is now on Floor 1"
  2480.                 sleep(2)
  2481.                 term.setCursorPos(1,16)
  2482.                 term.clearLine()
  2483.                 buttonwait1()
  2484.         end
  2485.  
  2486.  
  2487.         if (buttonPad2 == 1) or (buttonPad2 == 3) or (buttonPad2 == 4) or (buttonPad2 == 5) or (buttonPad2 == 6) or (buttonPad2 == 7) then
  2488.  
  2489.                 button2send()                   --  <------------------------- Dispatches CART to FLOOR [2] to pick up rider.
  2490.                 term.setCursorPos(1,16)
  2491.                 term.clearLine()
  2492. --              print "Elevator Cart is now on Floor 2"
  2493.                 sleep(2)
  2494.                 term.setCursorPos(1,16)
  2495.                 term.clearLine()
  2496.                 buttonwait2()
  2497.         end
  2498.  
  2499.  
  2500.         if (buttonPad3 == 1) or (buttonPad3 == 2) or (buttonPad3 == 4) or (buttonPad3 == 5) or (buttonPad3 == 6) or (buttonPad3 == 7) then
  2501.  
  2502.                 button3send()                   --  <------------------------- Dispatches CART to FLOOR [3] to pick up rider.
  2503.                 term.setCursorPos(1,16)
  2504.                 term.clearLine()
  2505. --              print "Elevator Cart is now on Floor 3"
  2506.                 sleep(2)
  2507.                 term.setCursorPos(1,16)
  2508.                 term.clearLine()
  2509.                 buttonwait3()
  2510.         end
  2511.  
  2512.  
  2513.         if (buttonPad4 == 1) or (buttonPad4 == 2) or (buttonPad4 == 3) or (buttonPad4 == 5) or (buttonPad4 == 6) or (buttonPad4 == 7) then
  2514.  
  2515.                 button4send()                   --  <------------------------- Dispatches CART to FLOOR [4] to pick up rider.
  2516.                 term.setCursorPos(1,16)
  2517.                 term.clearLine()
  2518. --              print "Elevator Cart is now on Floor 4"
  2519.                 sleep(2)
  2520.                 term.setCursorPos(1,16)
  2521.                 term.clearLine()
  2522.                 buttonwait4()
  2523.         end
  2524.  
  2525.  
  2526.         if (buttonPad5 == 1) or (buttonPad5 == 2) or (buttonPad5 == 3) or (buttonPad5 == 4) or (buttonPad5 == 6) or (buttonPad5 == 7) then
  2527.  
  2528.                 button5send()                   --  <------------------------- Dispatches CART to FLOOR [5] to pick up rider.
  2529.                 term.setCursorPos(1,16)
  2530.                 term.clearLine()
  2531. --              print "Elevator Cart is now on Floor 5"
  2532.                 sleep(2)
  2533.                 term.setCursorPos(1,16)
  2534.                 term.clearLine()
  2535.                 buttonwait5()
  2536.         end
  2537.  
  2538.  
  2539.         if (buttonPad6 == 1) or (buttonPad6 == 2) or (buttonPad6 == 3) or (buttonPad6 == 4) or (buttonPad6 == 5) or (buttonPad6 == 7) then
  2540.  
  2541.                 button6send()                   --  <------------------------- Dispatches CART to FLOOR [6] to pick up rider.
  2542.                 term.setCursorPos(1,16)
  2543.                 term.clearLine()
  2544. --              print "Elevator Cart is now on Floor 6"
  2545.                 sleep(2)
  2546.                 term.setCursorPos(1,16)
  2547.                 term.clearLine()
  2548.                 buttonwait6()
  2549.         end
  2550.  
  2551.  
  2552.  
  2553.         if (buttonPad7 == 1) or (buttonPad7 == 2) or (buttonPad7 == 3) or (buttonPad7 == 4) or (buttonPad7 == 5) or (buttonPad7 == 6) then
  2554.  
  2555.                 button7send()                   --  <------------------------- Dispatches CART to FLOOR [7] to pick up rider.
  2556.                 term.setCursorPos(1,16)
  2557.                 term.clearLine()
  2558. --              print "Elevator Cart is now on Floor 7"
  2559.                 sleep(2)
  2560.                 term.setCursorPos(1,16)
  2561.                 term.clearLine()
  2562.                 buttonwait7()
  2563.         end
  2564.     end
  2565. end
  2566.  
  2567.  
  2568.  
  2569.  
  2570.  
  2571.  
  2572.  
  2573.  
  2574.  
  2575.  
  2576.  
  2577.  
  2578.  
  2579.  
  2580.  
  2581.  
  2582.  
  2583.  
  2584.  
  2585.  
  2586.  
  2587.  
  2588.  
  2589.  
  2590.  
  2591.  
  2592.  
  2593.  
  2594.  
  2595.  
  2596.  
  2597.  
  2598.  
  2599.  
  2600.  
  2601.  
  2602.  
  2603.  
  2604.  
  2605.  
  2606. -- BEGIN PROGAM
  2607.  
  2608.  
  2609.  
  2610.  
  2611.  
  2612.  
  2613. term.clear()
  2614.  
  2615.  
  2616. parallel.waitForAll(checkPower, screen, txData, rxData, cartSensor, ScreenCommands, sniffer)
Add Comment
Please, Sign In to add comment