Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- RAILCRAFT ELEVATOR SERVER "A" VERSION 1.4 MARCH 13TH 2014
- -- DESIGNED AND WRITTEN BY "MYSTERYDUMP"
- -- WWW.MYSTERYDUMP.COM
- -- ****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.
- --- MODEM SETUP
- rednet.open("top")
- -- SET BUNDLED CABLES AND INITIALIZE IN/OUTPUTS (OFF)
- local cablePort1 = "right"
- local cablePort2 = "left"
- rs.setBundledOutput(cablePort1, 0 )
- rs.setBundledOutput(cablePort2, 0 )
- -- LOCALS
- local powerSwitch = 0
- local powerStatus = "Testing"
- local computerID7 = 116 -- FLOOR 7 <---- SET COMPUTER ID'S OF EACH COMPUTER CLIENT HERE *******ALSO NEEDS CHANGED IN THE txData Section!!!!!!*********
- local computerID6 = 113 -- FLOOR 6
- local computerID5 = 112 -- FLOOR 5
- local computerID4 = 108 -- FLOOR 4
- local computerID3 = 107 -- FLOOR 3
- local computerID2 = 105 -- FLOOR 2
- local computerID1 = 103 -- FLOOR 1
- local clientID = 0
- local buttonPad1 = 0 -- <---- Client transmits 1-7 to server for button pressed
- local buttonPad2 = 0
- local buttonPad3 = 0
- local buttonPad4 = 0
- local buttonPad5 = 0
- local buttonPad6 = 0
- local buttonPad7 = 0
- local token1 = 0 -- <---- - Tells the client 0=Standby 1=Ready 2=Busy 3=Hold
- local token2 = 0
- local token3 = 0
- local token4 = 0
- local token5 = 0
- local token6 = 0
- local token7 = 0
- local messageID1 = 0 -- <---- These are used to tell the client which message it is and which set of instruction code to use
- local messageID2 = 0
- local messageID3 = 0
- local messageID4 = 0
- local messageID5 = 0
- local messageID6 = 0
- local messageID7 = 0
- local elevatorKey1 = 1 -- <---- 1 = KEY (ON), 0 = KEY (OFF)
- local elevatorKey2 = 1
- local elevatorKey3 = 1
- local elevatorKey4 = 1
- local elevatorKey5 = 1
- local elevatorKey6 = 1
- local elevatorKey7 = 1
- -- CART SENSOR DATA
- local cartSensorData = {}
- cartSensorData[1] = false
- cartSensorData[2] = false
- cartSensorData[3] = false
- cartSensorData[4] = false
- cartSensorData[5] = false
- cartSensorData[6] = false
- cartSensorData[7] = false
- local cartSensorAnswer1 = "FALSE"
- local cartSensorAnswer2 = "FALSE"
- local cartSensorAnswer3 = "FALSE"
- local cartSensorAnswer4 = "FALSE"
- local cartSensorAnswer5 = "FALSE"
- local cartSensorAnswer6 = "FALSE"
- local cartSensorAnswer7 = "FALSE"
- -- TX DATA PACKETS
- local dataTXPacket = {}
- dataTXPacket[0] = (powerSwitch)
- dataTXPacket[1] = (token7) -- <------ ******* TX Created on Server - (token1) - it tells the client 0=Standby 1=Ready 2=Busy 3=Hold
- dataTXPacket[2] = (messageID7) -- <------ ******* TX Created on Server - (messageID1) - Sets of Server instructions to clients.
- dataTXPacket[3] = (elevatorKey7) -- <------ ******* TX Created on Server - (elevatorKey1) - Turns Client ON or OFF operation (needs powerSwitch + Key to operate)
- dataTXPacket[4] = (token6)
- dataTXPacket[5] = (messageID6)
- dataTXPacket[6] = (elevatorKey6)
- dataTXPacket[7] = (token5)
- dataTXPacket[8] = (messageID5)
- dataTXPacket[9] = (elevatorKey5)
- dataTXPacket[10] = (token4)
- dataTXPacket[11] = (messageID4)
- dataTXPacket[12] = (elevatorKey4)
- dataTXPacket[13] = (token3)
- dataTXPacket[14] = (messageID3)
- dataTXPacket[15] = (elevatorKey3)
- dataTXPacket[16] = (token2)
- dataTXPacket[17] = (messageID2)
- dataTXPacket[18] = (elevatorKey2)
- dataTXPacket[19] = (token1)
- dataTXPacket[20] = (messageID1)
- dataTXPacket[21] = (elevatorKey1)
- --------------------- Transmit DATA via RedNet (PARALLEL FUNCTION) -----------------------
- txData = function()
- while true do
- sleep(0)
- dataTXPacket[0] = (powerSwitch)
- dataTXPacket[1] = (token7)
- dataTXPacket[2] = (messageID7)
- dataTXPacket[3] = (elevatorKey7)
- dataTXPacket[4] = (token6)
- dataTXPacket[5] = (messageID6)
- dataTXPacket[6] = (elevatorKey6)
- dataTXPacket[7] = (token5)
- dataTXPacket[8] = (messageID5)
- dataTXPacket[9] = (elevatorKey5)
- dataTXPacket[10] = (token4)
- dataTXPacket[11] = (messageID4)
- dataTXPacket[12] = (elevatorKey4)
- dataTXPacket[13] = (token3)
- dataTXPacket[14] = (messageID3)
- dataTXPacket[15] = (elevatorKey3)
- dataTXPacket[16] = (token2)
- dataTXPacket[17] = (messageID2)
- dataTXPacket[18] = (elevatorKey2)
- dataTXPacket[19] = (token1)
- dataTXPacket[20] = (messageID1)
- dataTXPacket[21] = (elevatorKey1)
- local txMsg = textutils.serialize(dataTXPacket)
- 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)
- 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)
- 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)
- 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)
- 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)
- 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)
- 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)
- end
- end
- --------------------- Receive DATA via RedNet (PARALLEL FUNCTION) -----------------------
- local dataRXPacket = {}
- dataRXPacket[0] = 0
- dataRXPacket[1] = 0
- dataRXPacket[2] = 0
- dataRXPacket[3] = 0
- rxData = function()
- while true do
- sleep(0)
- local senderID, message = rednet.receive()
- dataRXPacket = textutils.unserialize(message)
- if senderID == (computerID1) then
- clientID = 1
- buttonPad1 = (dataRXPacket[2])
- end
- if senderID == (computerID2) then
- clientID = 2
- buttonPad2 = (dataRXPacket[2])
- end
- if senderID == (computerID3) then
- clientID = 3
- buttonPad3 = (dataRXPacket[2])
- end
- if senderID == (computerID4) then
- buttonPad4 = (dataRXPacket[2])
- clientID = 4
- end
- if senderID == (computerID5) then
- clientID = 5
- buttonPad5 = (dataRXPacket[2])
- end
- if senderID == (computerID6) then
- clientID = 6
- buttonPad6 = (dataRXPacket[2])
- end
- if senderID == (computerID7) then
- clientID = 7
- buttonPad7 = (dataRXPacket[2])
- end
- end
- end
- ------------------------------- CART SENSORS (PARALLEL FUNCTION) -------------------------------
- cartSensor = function()
- while true do
- sleep(0)
- sensor07 = redstone.testBundledInput(cablePort2, colors.white)
- if sensor07 == true then
- cartSensorData[7] = true
- cartSensorAnswer7 = "TRUE "
- term.setCursorPos(31,5)
- print (cartSensorAnswer7)
- else
- term.setCursorPos(31,5)
- cartSensorData[7] = false
- cartSensorAnswer7 = "FALSE"
- print (cartSensorAnswer7)
- end
- sensor06 = redstone.testBundledInput(cablePort2, colors.magenta)
- if sensor06 == true then
- cartSensorData[6] = true
- cartSensorAnswer6 = "TRUE "
- term.setCursorPos(31,6)
- print (cartSensorAnswer6)
- else
- term.setCursorPos(31,6)
- cartSensorData[6] = false
- cartSensorAnswer6 = "FALSE"
- print (cartSensorAnswer6)
- end
- sensor05 = redstone.testBundledInput(cablePort2, colors.yellow)
- if sensor05 == true then
- cartSensorData[5] = true
- cartSensorAnswer5 = "TRUE "
- term.setCursorPos(31,7)
- print (cartSensorAnswer5)
- else
- term.setCursorPos(31,7)
- cartSensorData[5] = false
- cartSensorAnswer5 = "FALSE"
- print (cartSensorAnswer5)
- end
- sensor04 = redstone.testBundledInput(cablePort2, colors.pink)
- if sensor04 == true then
- cartSensorData[4] = true
- cartSensorAnswer4 = "TRUE "
- term.setCursorPos(31,8)
- print (cartSensorAnswer4)
- else
- term.setCursorPos(31,8)
- cartSensorData[4] = false
- cartSensorAnswer4 = "FALSE"
- print (cartSensorAnswer4)
- end
- sensor03 = redstone.testBundledInput(cablePort2, colors.lightGray)
- if sensor03 == true then
- cartSensorData[3] = true
- cartSensorAnswer3 = "TRUE "
- term.setCursorPos(31,9)
- print (cartSensorAnswer3)
- else
- term.setCursorPos(31,9)
- cartSensorData[3] = false
- cartSensorAnswer3 = "FALSE"
- print (cartSensorAnswer3)
- end
- sensor02 = redstone.testBundledInput(cablePort2, colors.purple)
- if sensor02 == true then
- cartSensorData[2] = true
- cartSensorAnswer2 = "TRUE "
- term.setCursorPos(31,10)
- print (cartSensorAnswer2)
- else
- term.setCursorPos(31,10)
- cartSensorData[2] = false
- cartSensorAnswer2 = "FALSE"
- print (cartSensorAnswer2)
- end
- sensor01 = redstone.testBundledInput(cablePort2, colors.brown)
- if sensor01 == true then
- cartSensorData[1] = true
- cartSensorAnswer1 = "TRUE "
- term.setCursorPos(31,11)
- print (cartSensorAnswer1)
- else
- term.setCursorPos(31,11)
- cartSensorData[1] = false
- cartSensorAnswer1 = "FALSE"
- print (cartSensorAnswer1)
- end
- end
- end
- --------------------- POWER SWITCH (PARALLEL FUNCTION) ---------------------
- checkPower = function()
- while true do
- sleep(0)
- local power = redstone.testBundledInput(cablePort1, colors.green)
- if power == true then
- powerSwitch = 1
- powerStatus = "ONLINE "
- else
- powerSwitch = 0
- powerStatus = "OFFLINE"
- end
- end
- end
- ----------------- SCREEN COMMANDS (PARALLEL FUNCTION) ----------------
- ScreenCommands = function()
- term.setCursorPos(33,1)
- print " Reboot [R]"
- term.setCursorPos(1,18)
- print ("Elevator Button: [1] [2] [3] [4] [5] [6] [7]")
- while true do
- local event1, param1 = os.pullEvent ("char")
- if param1 == "1" then
- if powerSwitch == 0 then
- term.setCursorPos(1,16)
- term.clearLine()
- print "REQUEST DECLINED: System Power is OFFLINE"
- sleep(2)
- term.setCursorPos(1,16)
- term.clearLine()
- else
- button1send() -- <------------------------- SENDS CART TO FLOOR [1]
- term.setCursorPos(1,16)
- term.clearLine()
- print "Elevator Cart is now on Floor 1"
- sleep(2)
- term.setCursorPos(1,16)
- term.clearLine()
- buttonwait1()
- token1 = 0 -- <---- - Tells the client 0=Standby 1=Ready 2=Busy 3=Hold
- token2 = 0
- token3 = 0
- token4 = 0
- token5 = 0
- token6 = 0
- token7 = 0
- end
- end
- if param1 == "2" then
- if powerSwitch == 0 then
- term.setCursorPos(1,16)
- term.clearLine()
- print "REQUEST DECLINED: System Power is OFFLINE"
- sleep(2)
- term.setCursorPos(1,16)
- term.clearLine()
- else
- button2send() -- <------------------------- SENDS CART TO FLOOR [2]
- term.setCursorPos(1,16)
- term.clearLine()
- print "Elevator Cart is now on Floor 2"
- sleep(2)
- term.setCursorPos(1,16)
- term.clearLine()
- buttonwait2()
- token1 = 0 -- <---- - Tells the client 0=Standby 1=Ready 2=Busy 3=Hold
- token2 = 0
- token3 = 0
- token4 = 0
- token5 = 0
- token6 = 0
- token7 = 0
- end
- end
- if param1 == "3" then
- if powerSwitch == 0 then
- term.setCursorPos(1,16)
- term.clearLine()
- print "REQUEST DECLINED: System Power is OFFLINE"
- sleep(2)
- term.setCursorPos(1,16)
- term.clearLine()
- else
- button3send() -- <------------------------- SENDS CART TO FLOOR [3]
- term.setCursorPos(1,16)
- term.clearLine()
- print "Elevator Cart is now on Floor 3"
- sleep(2)
- term.setCursorPos(1,16)
- term.clearLine()
- buttonwait3()
- token1 = 0 -- <---- - Tells the client 0=Standby 1=Ready 2=Busy 3=Hold
- token2 = 0
- token3 = 0
- token4 = 0
- token5 = 0
- token6 = 0
- token7 = 0
- end
- end
- if param1 == "4" then
- if powerSwitch == 0 then
- term.setCursorPos(1,16)
- term.clearLine()
- print "REQUEST DECLINED: System Power is OFFLINE"
- sleep(2)
- term.setCursorPos(1,16)
- term.clearLine()
- else
- button4send() -- <------------------------- SENDS CART TO FLOOR [4]
- term.setCursorPos(1,16)
- term.clearLine()
- print "Elevator Cart is now on Floor 4"
- sleep(2)
- term.setCursorPos(1,16)
- term.clearLine()
- buttonwait4()
- token1 = 0 -- <---- - Tells the client 0=Standby 1=Ready 2=Busy 3=Hold
- token2 = 0
- token3 = 0
- token4 = 0
- token5 = 0
- token6 = 0
- token7 = 0
- end
- end
- if param1 == "5" then
- if powerSwitch == 0 then
- term.setCursorPos(1,16)
- term.clearLine()
- print "REQUEST DECLINED: System Power is OFFLINE"
- sleep(2)
- term.setCursorPos(1,16)
- term.clearLine()
- else
- button5send() -- <------------------------- SENDS CART TO FLOOR [5]
- term.setCursorPos(1,16)
- term.clearLine()
- print "Elevator Cart is now on Floor 5"
- sleep(2)
- term.setCursorPos(1,16)
- term.clearLine()
- buttonwait5()
- token1 = 0 -- <---- - Tells the client 0=Standby 1=Ready 2=Busy 3=Hold
- token2 = 0
- token3 = 0
- token4 = 0
- token5 = 0
- token6 = 0
- token7 = 0
- end
- end
- if param1 == "6" then
- if powerSwitch == 0 then
- term.setCursorPos(1,16)
- term.clearLine()
- print "REQUEST DECLINED: System Power is OFFLINE"
- sleep(2)
- term.setCursorPos(1,16)
- term.clearLine()
- else
- button6send() -- <------------------------- SENDS CART TO FLOOR [6]
- term.setCursorPos(1,16)
- term.clearLine()
- print "Elevator Cart is now on Floor 6"
- sleep(2)
- term.setCursorPos(1,16)
- term.clearLine()
- buttonwait6()
- token1 = 0 -- <---- - Tells the client 0=Standby 1=Ready 2=Busy 3=Hold
- token2 = 0
- token3 = 0
- token4 = 0
- token5 = 0
- token6 = 0
- token7 = 0
- end
- end
- if param1 == "7" then
- if powerSwitch == 0 then
- term.setCursorPos(1,16)
- term.clearLine()
- print "REQUEST DECLINED: System Power is OFFLINE"
- sleep(2)
- term.setCursorPos(1,16)
- term.clearLine()
- else
- button7send() -- <------------------------- SENDS CART TO FLOOR [7]
- term.setCursorPos(1,16)
- term.clearLine()
- print "Elevator Cart is now on Floor 7"
- sleep(2)
- term.setCursorPos(1,16)
- term.clearLine()
- buttonwait7()
- token1 = 0 -- <---- - Tells the client 0=Standby 1=Ready 2=Busy 3=Hold
- token2 = 0
- token3 = 0
- token4 = 0
- token5 = 0
- token6 = 0
- token7 = 0
- end
- end
- if param1 == "r" then -- <------------------------- REBOOT SERVER COMMAND [r]
- term.setCursorPos(33,1)
- print "Are you sure? [Y/N]"
- local event2, param2 = os.pullEvent ("char")
- if param2 == "y" then
- term.setCursorPos(33,1)
- print (" Rebooting...")
- sleep (1.5)
- os.reboot()
- elseif param2 == "Y" then
- term.setCursorPos(33,1)
- print (" Rebooting...")
- sleep (1.5)
- os.reboot()
- elseif param2 == "n" then
- term.setCursorPos(33,1)
- print " Reboot [R]"
- elseif param2 == "N" then
- term.setCursorPos(33,1)
- print " Reboot [R]"
- else
- term.setCursorPos(33,1)
- print (" Invalid Choice")
- sleep (1.5)
- term.setCursorPos(33,1)
- print " Reboot [R]"
- end
- end
- if param1 == "R" then -- <------------------------- REBOOT SERVER COMMAND [R]
- term.setCursorPos(33,1)
- print "Are you sure? [Y/N]"
- local event2, param2 = os.pullEvent ("char")
- if param2 == "y" then
- term.setCursorPos(33,1)
- print (" Rebooting...")
- sleep (1.5)
- os.reboot()
- elseif param2 == "Y" then
- term.setCursorPos(33,1)
- print (" Rebooting...")
- sleep (1.5)
- os.reboot()
- elseif param2 == "n" then
- term.setCursorPos(33,1)
- print " Reboot [R]"
- elseif param2 == "N" then
- term.setCursorPos(33,1)
- print " Reboot [R]"
- else
- term.setCursorPos(33,1)
- print (" Invalid Choice")
- sleep (1.5)
- term.setCursorPos(33,1)
- print " Reboot [R]"
- end
- end
- end
- end
- --------------------- SCREEN (PARALLEL FUNCTION) ---------------------
- screen = function()
- while true do
- sleep(0)
- term.setCursorPos(1,1)
- print "Elevator Control System v1.4a"
- term.setCursorPos(1,3)
- term.clearLine()
- print ("System Power: ", powerStatus)
- local time = os.time() -- <-------------- Onscreen Clock
- local day = os.day()
- time = textutils.formatTime(time, false)
- term.setCursorPos(27,3) -- <-------------- AJUST THIS LINE NUMBER IS THE "DAY" COUNT IS SPILLING OVER ONTO ANOTHER LINE.
- print("Day:", day, " Time: ", time)
- term.setCursorPos(1,13)
- print ("Client ID Communicating: ", clientID)
- --------------------- SCREEN / FLOOR 7 ---------------------
- term.setCursorPos(4,5)
- print "Floor 7:"
- if token7 == 0 then -- <---- - Tells the client 0=Standby 1=Active 2=Busy 3=Hold
- term.setCursorPos(13,5)
- print "STANDBY"
- end
- if token7 == 1 then
- term.setCursorPos(13,5)
- print "READY "
- end
- if token7 == 2 then
- term.setCursorPos(13,5)
- print "BUSY "
- end
- if token7 == 3 then
- term.setCursorPos(13,5)
- print "HOLD "
- end
- term.setCursorPos(23,5)
- print "Sensor:"
- term.setCursorPos(39,5)
- print ("Button: ", buttonPad7)
- --------------------- SCREEN / FLOOR 6 ---------------------
- term.setCursorPos(4,6)
- print "Floor 6:"
- if token6 == 0 then
- term.setCursorPos(13,6)
- print "STANDBY"
- end
- if token6 == 1 then
- term.setCursorPos(13,6)
- print "READY "
- end
- if token6 == 2 then
- term.setCursorPos(13,6)
- print "BUSY "
- end
- if token6 == 3 then
- term.setCursorPos(13,6)
- print "HOLD "
- end
- term.setCursorPos(23,6)
- print "Sensor:"
- term.setCursorPos(39,6)
- print ("Button: ", buttonPad6)
- --------------------- SCREEN / FLOOR 5 ---------------------
- term.setCursorPos(4,7)
- print "Floor 5:"
- if token5 == 0 then
- term.setCursorPos(13,7)
- print "STANDBY"
- end
- if token5 == 1 then
- term.setCursorPos(13,7)
- print "READY "
- end
- if token5 == 2 then
- term.setCursorPos(13,7)
- print "BUSY "
- end
- if token5 == 3 then
- term.setCursorPos(13,7)
- print "HOLD "
- end
- term.setCursorPos(23,7)
- print "Sensor:"
- term.setCursorPos(39,7)
- print ("Button: ", buttonPad5)
- --------------------- SCREEN / FLOOR 4 ---------------------
- term.setCursorPos(4,8)
- print "Floor 4:"
- if token4 == 0 then
- term.setCursorPos(13,8)
- print "STANDBY"
- end
- if token4 == 1 then
- term.setCursorPos(13,8)
- print "READY "
- end
- if token4 == 2 then
- term.setCursorPos(13,8)
- print "BUSY "
- end
- if token4 == 3 then
- term.setCursorPos(13,8)
- print "HOLD "
- end
- term.setCursorPos(23,8)
- print "Sensor:"
- term.setCursorPos(39,8)
- print ("Button: ", buttonPad4)
- --------------------- SCREEN / FLOOR 3 ---------------------
- term.setCursorPos(4,9)
- print "Floor 3:"
- if token3 == 0 then
- term.setCursorPos(13,9)
- print "STANDBY"
- end
- if token3 == 1 then
- term.setCursorPos(13,9)
- print "READY "
- end
- if token3 == 2 then
- term.setCursorPos(13,9)
- print "BUSY "
- end
- if token3 == 3 then
- term.setCursorPos(13,9)
- print "HOLD "
- end
- term.setCursorPos(23,9)
- print "Sensor:"
- term.setCursorPos(39,9)
- print ("Button: ", buttonPad3)
- --------------------- SCREEN / FLOOR 2 ---------------------
- term.setCursorPos(4,10)
- print "Floor 2:"
- if token2 == 0 then
- term.setCursorPos(13,10)
- print "STANDBY"
- end
- if token2 == 1 then
- term.setCursorPos(13,10)
- print "READY "
- end
- if token2 == 2 then
- term.setCursorPos(13,10)
- print "BUSY "
- end
- if token2 == 3 then
- term.setCursorPos(13,10)
- print "HOLD "
- end
- term.setCursorPos(23,10)
- print "Sensor:"
- term.setCursorPos(39,10)
- print ("Button: ", buttonPad2)
- --------------------- SCREEN / FLOOR 1 ---------------------
- term.setCursorPos(4,11)
- print "Floor 1:"
- if token1 == 0 then
- term.setCursorPos(13,11)
- print "STANDBY"
- end
- if token1 == 1 then
- term.setCursorPos(13,11)
- print "READY "
- end
- if token1 == 2 then
- term.setCursorPos(13,11)
- print "BUSY "
- end
- if token1 == 3 then
- term.setCursorPos(13,11)
- print "HOLD "
- end
- term.setCursorPos(23,11)
- print "Sensor:"
- term.setCursorPos(39,11)
- print ("Button: ", buttonPad1)
- end
- end
- --------------------- BUTTON COMMANDS ---------------------
- ---------------- PHASE 1 BUTTON COMMANDS / FLOOR 1 ----------------
- function killAll()
- redstone.setBundledOutput(cablePort1, 0)
- end
- function button7send()
- if sensor07 == false then
- token1 = 3 -- <---- - Tells the client 0=Standby 1=Ready 2=Busy 3=Hold
- token2 = 3
- token3 = 3
- token4 = 3
- token5 = 3
- token6 = 3
- token7 = 2
- term.clearLine()
- term.setCursorPos(1,16)
- print "Dispatching Elevator Cart to Floor 7"
- redstone.setBundledOutput(cablePort1, 0)
- sleep(.5)
- redstone.setBundledOutput(cablePort1, colors.orange+colors.red)
- sleep(.5)
- redstone.setBundledOutput(cablePort1, colors.orange)
- killfloor7()
- end
- if sensor07 == true then
- token1 = 3 -- <---- - Tells the client 0=Standby 1=Ready 2=Busy 3=Hold
- token2 = 3
- token3 = 3
- token4 = 3
- token5 = 3
- token6 = 3
- token7 = 2
- killfloor7()
- end
- end
- function button6send()
- if sensor06 == false then
- token1 = 3 -- <---- - Tells the client 0=Standby 1=Ready 2=Busy 3=Hold
- token2 = 3
- token3 = 3
- token4 = 3
- token5 = 3
- token6 = 2
- token7 = 3
- term.clearLine()
- term.setCursorPos(1,16)
- print "Dispatching Elevator Cart to Floor 6"
- redstone.setBundledOutput(cablePort1, 0)
- sleep(.5)
- redstone.setBundledOutput(cablePort1, colors.lightBlue+colors.red)
- sleep(.5)
- redstone.setBundledOutput(cablePort1, colors.lightBlue)
- killfloor6()
- end
- if sensor06 == true then
- token1 = 3 -- <---- - Tells the client 0=Standby 1=Ready 2=Busy 3=Hold
- token2 = 3
- token3 = 3
- token4 = 3
- token5 = 3
- token6 = 2
- token7 = 3
- killfloor6()
- end
- end
- function button5send()
- if sensor05 == false then
- token1 = 3 -- <---- - Tells the client 0=Standby 1=Ready 2=Busy 3=Hold
- token2 = 3
- token3 = 3
- token4 = 3
- token5 = 2
- token6 = 3
- token7 = 3
- term.clearLine()
- term.setCursorPos(1,16)
- print "Dispatching Elevator Cart to Floor 5"
- redstone.setBundledOutput(cablePort1, 0)
- sleep(.5)
- redstone.setBundledOutput(cablePort1, colors.lime+colors.red)
- sleep(.5)
- redstone.setBundledOutput(cablePort1, colors.lime)
- killfloor5()
- end
- if sensor05 == true then
- token1 = 3 -- <---- - Tells the client 0=Standby 1=Ready 2=Busy 3=Hold
- token2 = 3
- token3 = 3
- token4 = 3
- token5 = 2
- token6 = 3
- token7 = 3
- killfloor5()
- end
- end
- function button4send()
- if sensor04 == false then
- token1 = 3 -- <---- - Tells the client 0=Standby 1=Ready 2=Busy 3=Hold
- token2 = 3
- token3 = 3
- token4 = 2
- token5 = 3
- token6 = 3
- token7 = 3
- term.clearLine()
- term.setCursorPos(1,16)
- print "Dispatching Elevator Cart to Floor 4"
- redstone.setBundledOutput(cablePort1, 0)
- sleep(.5)
- redstone.setBundledOutput(cablePort1, colors.gray+colors.red)
- sleep(.5)
- redstone.setBundledOutput(cablePort1, colors.gray)
- killfloor4()
- end
- if sensor04 == true then
- token1 = 3 -- <---- - Tells the client 0=Standby 1=Ready 2=Busy 3=Hold
- token2 = 3
- token3 = 3
- token4 = 2
- token5 = 3
- token6 = 3
- token7 = 3
- killfloor4()
- end
- end
- function button3send()
- if sensor03 == false then
- token1 = 3 -- <---- - Tells the client 0=Standby 1=Ready 2=Busy 3=Hold
- token2 = 3
- token3 = 2
- token4 = 3
- token5 = 3
- token6 = 3
- token7 = 3
- term.clearLine()
- term.setCursorPos(1,16)
- print "Dispatching Elevator Cart to Floor 3"
- redstone.setBundledOutput(cablePort1, 0)
- sleep(.5)
- redstone.setBundledOutput(cablePort1, colors.cyan+colors.red)
- sleep(.5)
- redstone.setBundledOutput(cablePort1, colors.cyan)
- killfloor3()
- end
- if sensor03 == true then
- token1 = 3 -- <---- - Tells the client 0=Standby 1=Ready 2=Busy 3=Hold
- token2 = 3
- token3 = 2
- token4 = 3
- token5 = 3
- token6 = 3
- token7 = 3
- killfloor3()
- end
- end
- function button2send()
- if sensor02 == false then
- token1 = 3 -- <---- - Tells the client 0=Standby 1=Ready 2=Busy 3=Hold
- token2 = 2
- token3 = 3
- token4 = 3
- token5 = 3
- token6 = 3
- token7 = 3
- term.clearLine()
- term.setCursorPos(1,16)
- print "Dispatching Elevator Cart to Floor 2"
- redstone.setBundledOutput(cablePort1, 0)
- sleep(.5)
- redstone.setBundledOutput(cablePort1, colors.blue+colors.red)
- sleep(.5)
- redstone.setBundledOutput(cablePort1, colors.blue)
- killfloor2()
- end
- if sensor02 == true then
- token1 = 3 -- <---- - Tells the client 0=Standby 1=Ready 2=Busy 3=Hold
- token2 = 2
- token3 = 3
- token4 = 3
- token5 = 3
- token6 = 3
- token7 = 3
- killfloor2()
- end
- end
- function button1send()
- if sensor01 == false then
- token1 = 2 -- <---- - Tells the client 0=Standby 1=Ready 2=Busy 3=Hold
- token2 = 3
- token3 = 3
- token4 = 3
- token5 = 3
- token6 = 3
- token7 = 3
- term.clearLine()
- term.setCursorPos(1,16)
- print "Dispatching Elevator Cart to Floor 1"
- redstone.setBundledOutput(cablePort1, 0)
- sleep(.5)
- redstone.setBundledOutput(cablePort1, colors.red)
- sleep(.5)
- redstone.setBundledOutput(cablePort1, 0)
- killfloor1()
- end
- if sensor01 == true then
- token1 = 2 -- <---- - Tells the client 0=Standby 1=Ready 2=Busy 3=Hold
- token2 = 3
- token3 = 3
- token4 = 3
- token5 = 3
- token6 = 3
- token7 = 3
- killfloor1()
- end
- end
- ---------------- PHASE 2 BUTTON COMMANDS ----------------
- function buttonwait7()
- token1 = 3 -- <---- - Tells the client 0=Standby 1=Ready 2=Busy 3=Hold
- token2 = 3
- token3 = 3
- token4 = 3
- token5 = 3
- token6 = 3
- token7 = 1
- -- <---------------- PHASE 2 FLOOR 7 ----------------
- sleep(0)
- if clientID == 7 then
- if buttonPad7 == 6 then
- sleep(1)
- term.setCursorPos(1,16)
- print "Floor 7 to 6: - [SYSTEM ARMED & LOCKED]"
- redstone.setBundledOutput(cablePort1, colors.lightBlue)
- KillAfterWait6()
- buttonPad7 = 0
- clientID = 0
- end
- end
- if clientID == 7 then
- if buttonPad7 == 5 then
- sleep(1)
- term.setCursorPos(1,16)
- print "Floor 7 to 5: - [SYSTEM ARMED & LOCKED]"
- redstone.setBundledOutput(cablePort1, colors.lime)
- KillAfterWait5()
- buttonPad7 = 0
- clientID = 0
- end
- end
- if clientID == 7 then
- if buttonPad7 == 4 then
- sleep(1)
- term.setCursorPos(1,16)
- print "Floor 7 to 4: - [SYSTEM ARMED & LOCKED]"
- redstone.setBundledOutput(cablePort1, colors.gray)
- KillAfterWait4()
- buttonPad7 = 0
- clientID = 0
- end
- end
- if clientID == 7 then
- if buttonPad7 == 3 then
- sleep(1)
- term.setCursorPos(1,16)
- print "Floor 7 to 3: - [SYSTEM ARMED & LOCKED]"
- redstone.setBundledOutput(cablePort1, colors.cyan)
- KillAfterWait3()
- buttonPad7 = 0
- clientID = 0
- end
- end
- if clientID == 7 then
- if buttonPad7 == 2 then
- sleep(1)
- term.setCursorPos(1,16)
- print "Floor 7 to 2: - [SYSTEM ARMED & LOCKED]"
- redstone.setBundledOutput(cablePort1, colors.blue)
- KillAfterWait2()
- buttonPad7 = 0
- clientID = 0
- end
- end
- if clientID == 7 then
- if buttonPad7 == 1 then
- sleep(1)
- term.setCursorPos(1,16)
- print "Floor 7 to 1: - [SYSTEM ARMED & LOCKED]"
- redstone.setBundledOutput(cablePort1, 0)
- KillAfterWait1()
- buttonPad7 = 0
- clientID = 0
- end
- end
- end
- function buttonwait6() -- <---------------- PHASE 2 FLOOR 6 ----------------
- token1 = 3 -- <---- - Tells the client 0=Standby 1=Ready 2=Busy 3=Hold
- token2 = 3
- token3 = 3
- token4 = 3
- token5 = 3
- token6 = 1
- token7 = 3
- sleep(0)
- if clientID == 6 then
- if buttonPad6 == 7 then
- sleep(1)
- term.setCursorPos(1,16)
- print "Floor 6 to 7: - [SYSTEM ARMED & LOCKED]"
- redstone.setBundledOutput(cablePort1, colors.orange)
- KillAfterWait7()
- buttonPad6 = 0
- clientID = 0
- end
- end
- if clientID == 6 then
- if buttonPad6 == 5 then
- sleep(1)
- term.setCursorPos(1,16)
- print "Floor 6 to 5: - [SYSTEM ARMED & LOCKED]"
- redstone.setBundledOutput(cablePort1, colors.lime)
- KillAfterWait5()
- buttonPad6 = 0
- clientID = 0
- end
- end
- if clientID == 6 then
- if buttonPad6 == 4 then
- sleep(1)
- term.setCursorPos(1,16)
- print "Floor 6 to 4: - [SYSTEM ARMED & LOCKED]"
- redstone.setBundledOutput(cablePort1, colors.gray)
- KillAfterWait4()
- buttonPad6 = 0
- clientID = 0
- end
- end
- if clientID == 6 then
- if buttonPad6 == 3 then
- sleep(1)
- term.setCursorPos(1,16)
- print "Floor 6 to 3: - [SYSTEM ARMED & LOCKED]"
- redstone.setBundledOutput(cablePort1, colors.cyan)
- KillAfterWait3()
- buttonPad6 = 0
- clientID = 0
- end
- end
- if clientID == 6 then
- if buttonPad6 == 2 then
- sleep(1)
- term.setCursorPos(1,16)
- print "Floor 6 to 2: - [SYSTEM ARMED & LOCKED]"
- redstone.setBundledOutput(cablePort1, colors.blue)
- KillAfterWait2()
- buttonPad6 = 0
- clientID = 0
- end
- end
- if clientID == 6 then
- if buttonPad6 == 1 then
- sleep(1)
- term.setCursorPos(1,16)
- print "Floor 6 to 1: - [SYSTEM ARMED & LOCKED]"
- redstone.setBundledOutput(cablePort1, 0)
- KillAfterWait1()
- buttonPad6 = 0
- clientID = 0
- end
- end
- end
- function buttonwait5() -- <---------------- PHASE 2 FLOOR 5 ----------------
- token1 = 3 -- <---- - Tells the client 0=Standby 1=Ready 2=Busy 3=Hold
- token2 = 3
- token3 = 3
- token4 = 3
- token5 = 1
- token6 = 3
- token7 = 3
- sleep(0)
- if clientID == 5 then
- if buttonPad5 == 7 then
- sleep(1)
- term.setCursorPos(1,16)
- print "Floor 5 to 7: - [SYSTEM ARMED & LOCKED]"
- redstone.setBundledOutput(cablePort1, colors.orange)
- KillAfterWait7()
- buttonPad5 = 0
- clientID = 0
- end
- end
- if clientID == 5 then
- if buttonPad5 == 6 then
- sleep(1)
- term.setCursorPos(1,16)
- print "Floor 5 to 6: - [SYSTEM ARMED & LOCKED]"
- redstone.setBundledOutput(cablePort1, colors.lightBlue)
- KillAfterWait6()
- buttonPad5 = 0
- clientID = 0
- end
- end
- if clientID == 5 then
- if buttonPad5 == 4 then
- sleep(1)
- term.setCursorPos(1,16)
- print "Floor 5 to 4: - [SYSTEM ARMED & LOCKED]"
- redstone.setBundledOutput(cablePort1, colors.gray)
- KillAfterWait4()
- buttonPad5 = 0
- clientID = 0
- end
- end
- if clientID == 5 then
- if buttonPad5 == 3 then
- sleep(1)
- term.setCursorPos(1,16)
- print "Floor 5 to 3: - [SYSTEM ARMED & LOCKED]"
- redstone.setBundledOutput(cablePort1, colors.cyan)
- KillAfterWait3()
- buttonPad5 = 0
- clientID = 0
- end
- end
- if clientID == 5 then
- if buttonPad5 == 2 then
- sleep(1)
- term.setCursorPos(1,16)
- print "Floor 5 to 2: - [SYSTEM ARMED & LOCKED]"
- redstone.setBundledOutput(cablePort1, colors.blue)
- KillAfterWait2()
- buttonPad5 = 0
- clientID = 0
- end
- end
- if clientID == 5 then
- if buttonPad5 == 1 then
- sleep(1)
- term.setCursorPos(1,16)
- print "Floor 5 to 1: - [SYSTEM ARMED & LOCKED]"
- redstone.setBundledOutput(cablePort1, 0)
- KillAfterWait1()
- buttonPad5 = 0
- clientID = 0
- end
- end
- end
- function buttonwait4() -- <---------------- PHASE 2 FLOOR 4 ----------------
- token1 = 3 -- <---- - Tells the client 0=Standby 1=Ready 2=Busy 3=Hold
- token2 = 3
- token3 = 3
- token4 = 1
- token5 = 3
- token6 = 3
- token7 = 3
- sleep(0)
- if clientID == 4 then
- if buttonPad4 == 7 then
- sleep(1)
- term.setCursorPos(1,16)
- print "Floor 4 to 7: - [SYSTEM ARMED & LOCKED]"
- redstone.setBundledOutput(cablePort1, colors.orange)
- KillAfterWait7()
- buttonPad4 = 0
- clientID = 0
- end
- end
- if clientID == 4 then
- if buttonPad4 == 6 then
- sleep(1)
- term.setCursorPos(1,16)
- print "Floor 4 to 6: - [SYSTEM ARMED & LOCKED]"
- redstone.setBundledOutput(cablePort1, colors.lightBlue)
- KillAfterWait6()
- buttonPad4 = 0
- clientID = 0
- end
- end
- if clientID == 4 then
- if buttonPad4 == 5 then
- sleep(1)
- term.setCursorPos(1,16)
- print "Floor 4 to 5: - [SYSTEM ARMED & LOCKED]"
- redstone.setBundledOutput(cablePort1, colors.lime)
- KillAfterWait5()
- buttonPad4 = 0
- clientID = 0
- end
- end
- if clientID == 4 then
- if buttonPad4 == 3 then
- sleep(1)
- term.setCursorPos(1,16)
- print "Floor 4 to 3: - [SYSTEM ARMED & LOCKED]"
- redstone.setBundledOutput(cablePort1, colors.cyan)
- KillAfterWait3()
- buttonPad4 = 0
- end
- end
- if clientID == 4 then
- if buttonPad4 == 2 then
- sleep(1)
- term.setCursorPos(1,16)
- print "Floor 4 to 2: - [SYSTEM ARMED & LOCKED]"
- redstone.setBundledOutput(cablePort1, colors.blue)
- KillAfterWait2()
- buttonPad4 = 0
- clientID = 0
- end
- end
- if clientID == 4 then
- if buttonPad4 == 1 then
- sleep(1)
- term.setCursorPos(1,16)
- print "Floor 4 to 1: - [SYSTEM ARMED & LOCKED]"
- redstone.setBundledOutput(cablePort1, 0)
- KillAfterWait1()
- buttonPad4 = 0
- clientID = 0
- end
- end
- end
- function buttonwait3() -- <---------------- PHASE 2 FLOOR 3 ----------------
- token1 = 3 -- <---- - Tells the client 0=Standby 1=Ready 2=Busy 3=Hold
- token2 = 3
- token3 = 1
- token4 = 3
- token5 = 3
- token6 = 3
- token7 = 3
- sleep(0)
- if clientID == 3 then
- if buttonPad3 == 7 then
- sleep(1)
- term.setCursorPos(1,16)
- print "Floor 3 to 7: - [SYSTEM ARMED & LOCKED]"
- redstone.setBundledOutput(cablePort1, colors.orange)
- KillAfterWait7()
- buttonPad3 = 0
- clientID = 0
- end
- end
- if clientID == 3 then
- if buttonPad3 == 6 then
- sleep(1)
- term.setCursorPos(1,16)
- print "Floor 3 to 6: - [SYSTEM ARMED & LOCKED]"
- redstone.setBundledOutput(cablePort1, colors.lightBlue)
- KillAfterWait6()
- buttonPad3 = 0
- clientID = 0
- end
- end
- if clientID == 3 then
- if buttonPad3 == 5 then
- sleep(1)
- term.setCursorPos(1,16)
- print "Floor 3 to 5: - [SYSTEM ARMED & LOCKED]"
- redstone.setBundledOutput(cablePort1, colors.lime)
- KillAfterWait5()
- buttonPad3 = 0
- clientID = 0
- end
- end
- if clientID == 3 then
- if buttonPad3 == 4 then
- sleep(1)
- term.setCursorPos(1,16)
- print "Floor 3 to 4: - [SYSTEM ARMED & LOCKED]"
- redstone.setBundledOutput(cablePort1, colors.gray)
- KillAfterWait4()
- buttonPad3 = 0
- clientID = 0
- end
- end
- if clientID == 3 then
- if buttonPad3 == 2 then
- sleep(1)
- term.setCursorPos(1,16)
- print "Floor 3 to 2: - [SYSTEM ARMED & LOCKED]"
- redstone.setBundledOutput(cablePort1, colors.blue)
- KillAfterWait2()
- buttonPad3 = 0
- clientID = 0
- end
- end
- if clientID == 3 then
- if buttonPad3 == 1 then
- sleep(1)
- term.setCursorPos(1,16)
- print "Floor 3 to 1: - [SYSTEM ARMED & LOCKED]"
- redstone.setBundledOutput(cablePort1, 0)
- KillAfterWait1()
- buttonPad3 = 0
- clientID = 0
- end
- end
- end
- function buttonwait2() -- <---------------- PHASE 2 FLOOR 2 ----------------
- token1 = 3 -- <---- - Tells the client 0=Standby 1=Ready 2=Busy 3=Hold
- token2 = 1
- token3 = 3
- token4 = 3
- token5 = 3
- token6 = 3
- token7 = 3
- sleep(0)
- if clientID == 2 then
- if buttonPad2 == 7 then
- sleep(1)
- term.setCursorPos(1,16)
- print "Floor 2 to 7: - [SYSTEM ARMED & LOCKED]"
- redstone.setBundledOutput(cablePort1, colors.orange)
- KillAfterWait7()
- buttonPad2 = 0
- clientID = 0
- end
- end
- if clientID == 2 then
- if buttonPad2 == 6 then
- sleep(1)
- term.setCursorPos(1,16)
- print "Floor 2 to 6: - [SYSTEM ARMED & LOCKED]"
- redstone.setBundledOutput(cablePort1, colors.lightBlue)
- KillAfterWait6()
- buttonPad2 = 0
- clientID = 0
- end
- end
- if clientID == 2 then
- if buttonPad2 == 5 then
- sleep(1)
- term.setCursorPos(1,16)
- print "Floor 2 to 5: - [SYSTEM ARMED & LOCKED]"
- redstone.setBundledOutput(cablePort1, colors.lime)
- KillAfterWait5()
- buttonPad2 = 0
- clientID = 0
- end
- end
- if clientID == 2 then
- if buttonPad2 == 4 then
- sleep(1)
- term.setCursorPos(1,16)
- print "Floor 2 to 4: - [SYSTEM ARMED & LOCKED]"
- redstone.setBundledOutput(cablePort1, colors.gray)
- KillAfterWait4()
- buttonPad2 = 0
- clientID = 0
- end
- end
- if clientID == 2 then
- if buttonPad2 == 3 then
- sleep(1)
- term.setCursorPos(1,16)
- print "Floor 2 to 3: - [SYSTEM ARMED & LOCKED]"
- redstone.setBundledOutput(cablePort1, colors.cyan)
- KillAfterWait3()
- buttonPad2 = 0
- clientID = 0
- end
- end
- if clientID == 2 then
- if buttonPad2 == 1 then
- sleep(1)
- term.setCursorPos(1,16)
- print "Floor 2 to 1: - [SYSTEM ARMED & LOCKED]"
- redstone.setBundledOutput(cablePort1, 0)
- KillAfterWait1()
- buttonPad2 = 0
- clientID = 0
- end
- end
- end
- function buttonwait1() -- <---------------- PHASE 2 FLOOR 1 ----------------
- token1 = 1 -- <---- - Tells the client 0=Standby 1=Ready 2=Busy 3=Hold
- token2 = 3
- token3 = 3
- token4 = 3
- token5 = 3
- token6 = 3
- token7 = 3
- sleep(0)
- if clientID == 1 then
- if buttonPad1 == 7 then
- sleep(1)
- term.setCursorPos(1,16)
- print "Floor 1 to 7: - [SYSTEM ARMED & LOCKED]"
- redstone.setBundledOutput(cablePort1, colors.orange)
- KillAfterWait7()
- buttonPad1 = 0
- clientID = 0
- end
- end
- if clientID == 1 then
- if buttonPad1 == 6 then
- sleep(1)
- term.setCursorPos(1,16)
- print "Floor 1 to 6: - [SYSTEM ARMED & LOCKED]"
- redstone.setBundledOutput(cablePort1, colors.lightBlue)
- KillAfterWait6()
- buttonPad1 = 0
- clientID = 0
- end
- end
- if clientID == 1 then
- if buttonPad1 == 5 then
- sleep(1)
- term.setCursorPos(1,16)
- print "Floor 1 to 5: - [SYSTEM ARMED & LOCKED]"
- redstone.setBundledOutput(cablePort1, colors.lime)
- KillAfterWait5()
- buttonPad1 = 0
- clientID = 0
- end
- end
- if clientID == 1 then
- if buttonPad1 == 4 then
- sleep(1)
- term.setCursorPos(1,16)
- print "Floor 1 to 4: - [SYSTEM ARMED & LOCKED]"
- redstone.setBundledOutput(cablePort1, colors.gray)
- KillAfterWait4()
- buttonPad1 = 0
- clientID = 0
- end
- end
- if clientID == 1 then
- if buttonPad1 == 3 then
- sleep(1)
- term.setCursorPos(1,16)
- print "Floor 1 to 3: - [SYSTEM ARMED & LOCKED]"
- redstone.setBundledOutput(cablePort1, colors.cyan)
- KillAfterWait3()
- buttonPad1 = 0
- clientID = 0
- end
- end
- if clientID == 1 then
- if buttonPad1 == 2 then
- sleep(1)
- term.setCursorPos(1,16)
- print "Floor 1 to 2: - [SYSTEM ARMED & LOCKED]"
- redstone.setBundledOutput(cablePort1, colors.blue)
- KillAfterWait2()
- buttonPad1 = 0
- clientID = 0
- end
- end
- end
- function KillAfterWait1()
- while true do
- sleep(0)
- if cartSensorData[1] == true then
- redstone.setBundledOutput(cablePort1, 0)
- term.setCursorPos(1,16)
- print "Elevator Status: Ready "
- token1 = 0 -- <---- - Tells the client 0=Standby 1=Ready 2=Busy 3=Hold
- token2 = 0
- token3 = 0
- token4 = 0
- token5 = 0
- token6 = 0
- token7 = 0
- break end
- end
- end
- function KillAfterWait2()
- while true do
- sleep(0)
- if cartSensorData[2] == true then
- redstone.setBundledOutput(cablePort1, 0)
- term.setCursorPos(1,16)
- print "Elevator Status: Ready "
- token1 = 0 -- <---- - Tells the client 0=Standby 1=Ready 2=Busy 3=Hold
- token2 = 0
- token3 = 0
- token4 = 0
- token5 = 0
- token6 = 0
- token7 = 0
- break end
- end
- end
- function KillAfterWait3()
- while true do
- sleep(0)
- if cartSensorData[3] == true then
- redstone.setBundledOutput(cablePort1, 0)
- term.setCursorPos(1,16)
- print "Elevator Status: Ready "
- token1 = 0 -- <---- - Tells the client 0=Standby 1=Ready 2=Busy 3=Hold
- token2 = 0
- token3 = 0
- token4 = 0
- token5 = 0
- token6 = 0
- token7 = 0
- break end
- end
- end
- function KillAfterWait4()
- while true do
- sleep(0)
- if cartSensorData[4] == true then
- redstone.setBundledOutput(cablePort1, 0)
- term.setCursorPos(1,16)
- print "Elevator Status: Ready "
- token1 = 0 -- <---- - Tells the client 0=Standby 1=Ready 2=Busy 3=Hold
- token2 = 0
- token3 = 0
- token4 = 0
- token5 = 0
- token6 = 0
- token7 = 0
- break end
- end
- end
- function KillAfterWait5()
- while true do
- sleep(0)
- if cartSensorData[5] == true then
- redstone.setBundledOutput(cablePort1, 0)
- term.setCursorPos(1,16)
- print "Elevator Status: Ready "
- token1 = 0 -- <---- - Tells the client 0=Standby 1=Ready 2=Busy 3=Hold
- token2 = 0
- token3 = 0
- token4 = 0
- token5 = 0
- token6 = 0
- token7 = 0
- break end
- end
- end
- function KillAfterWait6()
- while true do
- sleep(0)
- if cartSensorData[6] == true then
- redstone.setBundledOutput(cablePort1, 0)
- term.setCursorPos(1,16)
- print "Elevator Status: Ready "
- token1 = 0 -- <---- - Tells the client 0=Standby 1=Ready 2=Busy 3=Hold
- token2 = 0
- token3 = 0
- token4 = 0
- token5 = 0
- token6 = 0
- token7 = 0
- break end
- end
- end
- function KillAfterWait7()
- while true do
- sleep(0)
- if cartSensorData[7] == true then
- redstone.setBundledOutput(cablePort1, 0)
- term.setCursorPos(1,16)
- print "Elevator Status: Ready "
- token1 = 0 -- <---- - Tells the client 0=Standby 1=Ready 2=Busy 3=Hold
- token2 = 0
- token3 = 0
- token4 = 0
- token5 = 0
- token6 = 0
- token7 = 0
- break end
- end
- end
- ---------------- KILL FLOOR POWER COMMANDS ----------------
- function killfloor1()
- while true do
- sleep(0)
- if cartSensorData[1] == true then
- killAll()
- break
- end
- end
- end
- function killfloor2()
- while true do
- sleep(0)
- if cartSensorData[2] == true then
- killAll()
- break
- end
- end
- end
- function killfloor3()
- while true do
- sleep(0)
- if cartSensorData[3] == true then
- killAll()
- break
- end
- end
- end
- function killfloor4()
- while true do
- sleep(0)
- if cartSensorData[4] == true then
- killAll()
- break
- end
- end
- end
- function killfloor5()
- while true do
- sleep(0)
- if cartSensorData[5] == true then
- killAll()
- break
- end
- end
- end
- function killfloor6()
- while true do
- sleep(0)
- if cartSensorData[6] == true then
- killAll()
- break
- end
- end
- end
- function killfloor7()
- while true do
- sleep(0)
- if cartSensorData[7] == true then
- killAll()
- break
- end
- end
- end
- -- SNIFFER
- sniffer = function()
- while true do
- sleep(0)
- if (buttonPad1 == 2) or (buttonPad1 == 3) or (buttonPad1 == 4) or (buttonPad1 == 5) or (buttonPad1 == 6) or (buttonPad1 == 7) then
- button1send() -- <------------------------- Dispatches CART to FLOOR [1] to pick up rider.
- term.setCursorPos(1,16)
- term.clearLine()
- -- print "Elevator Cart is now on Floor 1"
- sleep(2)
- term.setCursorPos(1,16)
- term.clearLine()
- buttonwait1()
- end
- if (buttonPad2 == 1) or (buttonPad2 == 3) or (buttonPad2 == 4) or (buttonPad2 == 5) or (buttonPad2 == 6) or (buttonPad2 == 7) then
- button2send() -- <------------------------- Dispatches CART to FLOOR [2] to pick up rider.
- term.setCursorPos(1,16)
- term.clearLine()
- -- print "Elevator Cart is now on Floor 2"
- sleep(2)
- term.setCursorPos(1,16)
- term.clearLine()
- buttonwait2()
- end
- if (buttonPad3 == 1) or (buttonPad3 == 2) or (buttonPad3 == 4) or (buttonPad3 == 5) or (buttonPad3 == 6) or (buttonPad3 == 7) then
- button3send() -- <------------------------- Dispatches CART to FLOOR [3] to pick up rider.
- term.setCursorPos(1,16)
- term.clearLine()
- -- print "Elevator Cart is now on Floor 3"
- sleep(2)
- term.setCursorPos(1,16)
- term.clearLine()
- buttonwait3()
- end
- if (buttonPad4 == 1) or (buttonPad4 == 2) or (buttonPad4 == 3) or (buttonPad4 == 5) or (buttonPad4 == 6) or (buttonPad4 == 7) then
- button4send() -- <------------------------- Dispatches CART to FLOOR [4] to pick up rider.
- term.setCursorPos(1,16)
- term.clearLine()
- -- print "Elevator Cart is now on Floor 4"
- sleep(2)
- term.setCursorPos(1,16)
- term.clearLine()
- buttonwait4()
- end
- if (buttonPad5 == 1) or (buttonPad5 == 2) or (buttonPad5 == 3) or (buttonPad5 == 4) or (buttonPad5 == 6) or (buttonPad5 == 7) then
- button5send() -- <------------------------- Dispatches CART to FLOOR [5] to pick up rider.
- term.setCursorPos(1,16)
- term.clearLine()
- -- print "Elevator Cart is now on Floor 5"
- sleep(2)
- term.setCursorPos(1,16)
- term.clearLine()
- buttonwait5()
- end
- if (buttonPad6 == 1) or (buttonPad6 == 2) or (buttonPad6 == 3) or (buttonPad6 == 4) or (buttonPad6 == 5) or (buttonPad6 == 7) then
- button6send() -- <------------------------- Dispatches CART to FLOOR [6] to pick up rider.
- term.setCursorPos(1,16)
- term.clearLine()
- -- print "Elevator Cart is now on Floor 6"
- sleep(2)
- term.setCursorPos(1,16)
- term.clearLine()
- buttonwait6()
- end
- if (buttonPad7 == 1) or (buttonPad7 == 2) or (buttonPad7 == 3) or (buttonPad7 == 4) or (buttonPad7 == 5) or (buttonPad7 == 6) then
- button7send() -- <------------------------- Dispatches CART to FLOOR [7] to pick up rider.
- term.setCursorPos(1,16)
- term.clearLine()
- -- print "Elevator Cart is now on Floor 7"
- sleep(2)
- term.setCursorPos(1,16)
- term.clearLine()
- buttonwait7()
- end
- end
- end
- -- BEGIN PROGAM
- term.clear()
- parallel.waitForAll(checkPower, screen, txData, rxData, cartSensor, ScreenCommands, sniffer)
Add Comment
Please, Sign In to add comment