Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --Run keydetect--
- shell.run(".keydetect")
- --Chatbox stuff--
- chatboxFound = false
- if peripheral.find("chatbox") then
- chatbox = peripheral.find("chatbox")
- chatbox.setLabel("ZiR")
- chatbox.tell("_Zircon_","Computer ID: "..os.getComputerID().." started!")
- chatboxFound = true
- end
- --Modem Stuff--
- local modem = peripheral.wrap("back")
- modem.open(5)
- --The Code--
- os.pullEvent = os.pullEventRaw
- local players = "_Zircon_"
- local failSleep = 2
- local successSleep = 2
- local doorLoc = "left"
- while true do
- function start()
- if term.isColor() then
- term.setBackgroundColor(colors.green)
- term.setTextColor(colors.lime)
- end
- term.clear()
- term.setCursorPos(1,1)
- end
- start()
- print("Only "..players.." can unlock this door!")
- local event, side, player = os.pullEvent()
- if event == "player" and players:find(player) then
- term.setTextColor(colors.lightBlue)
- print("Door Unlocked!")
- rs.setOutput(doorLoc, true)
- sleep(successSleep)
- rs.setOutput(doorLoc, false)
- start()
- elseif event == "player" then
- term.setTextColor(colors.red)
- print("Sorry, only "..players.." can unlock this door!")
- print("Sleeping for "..failSleep.." seconds")
- sleep(failSleep)
- start()
- end
- local event, modemSide, senderChannel, replyChannel, message, senderDistance = os.pullEvent("modem_message")
- if event == "modem_message" then
- if modemSide == "back" then
- if senderChannel == 5 then
- if replyChannel == 5 then
- if message == "housedooropen" then
- rs.setOutput(doorLoc, true)
- sleep(successSleep)
- rs.setOutput(doorLoc, false)
- modem.transmit(5,5,"Door Unlocked!")
- end
- end
- end
- end
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement