Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --Wrap modem and open Rednet on left of Computer
- rednet.close("left")
- rednet.open("left")
- --Set variable for and wrap touchscreen on top of Computer
- m = peripheral.wrap("top")
- --Check for Restone Output
- local rsCheck = redstone.getOutput("bottom")
- --Build our Tables
- floorID = {"591", "590", "584", "589", "644","702", "769"} --Ids of the computers
- floorNAME = {"Power","Sorting","Storage","Farming","Library","Control", "MobFarm"} --Names of the floors
- floorNUM = {} --Giving Index Values to the Floors
- for i,v in ipairs(floorID) do
- floorNUM[v] = i
- end
- --Write our buttons
- m.clear()
- ymin = 1
- for i = 1,table.getn(floorID) do
- m.setCursorPos(1,ymin)
- m.write(floorNAME[i])
- ymin = ymin + 1
- end
- --Start Loop
- while true do
- local compID = os.getComputerID()
- local event,senderID,message,y = os.pullEvent()
- --Check for user input
- if event == "monitor_touch" then
- if floorID[y] == tostring(compID) and rsCheck == false then
- rednet.broadcast("Clear Elevator Redstone")
- print("Clearing Redstone Elsewhere")
- print("Calling Elevator Here")
- redstone.setOutput("bottom",true)
- elseif floorID[y] == tostring(compID) and rsCheck == true then
- print("Elevator Already Here")
- else
- rednet.broadcast(floorID[y])
- print( "Message Sent to ",floorID[y] )
- redstone.setOutput("bottom",false)
- end
- --Look for Rednet Messages
- elseif event == "rednet_message" then
- if senderID == compID and rsCheck == false and message == tostring(compID) then
- print("Calling Elevator")
- rs.setOutput("bottom",true)
- elseif senderID == compID and rsCheck == true and message == tostring( compID) then
- print("Elevator Here Already")
- elseif senderID ~= compID then
- print("Command from ",senderID," to ",message)
- --If message is the Id of the current Comp, turn redstone on
- if message == tostring(compID) then
- redstone.setOutput("bottom",true)
- print("Calling Elevator")
- elseif message == "Clear Elevator Redstone" then
- print("Elevator got called to computer ",senderID)
- redstone.setOutput("bottom",false)
- else
- for i = 1,table.getn(floorID) do
- if message == floorID[i] then
- print("Elevator going to computer ",message)
- redstone.setOutput("bottom",false)
- else
- print("Not for Elevator")
- end
- end
- end
- end
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement