Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function monReset()
- mon = peripheral.wrap("monitor_0")
- mon.clear()
- mon.setCursorPos(1,1)
- mon.setTextScale(5)
- end
- function rs(state)
- if state == true then
- redstone.setOutput("right",true)
- redstone.setOutput("back",true)
- redstone.setOutput("left",true)
- redstone.setOutput("front",true)
- redstone.setOutput("top",true)
- redstone.setOutput("bottom",true)
- elseif state == false then
- redstone.setOutput("right",false)
- redstone.setOutput("back",false)
- redstone.setOutput("left",false)
- redstone.setOutput("front",false)
- redstone.setOutput("top",false)
- redstone.setOutput("bottom",false)
- end
- end
- thisDoor = "mainDoor"
- monReset()
- --mon.setTextColor(colors.red)
- mon.write("Closed")
- permissionOP = "do"
- mod = peripheral.wrap("bottom")
- modem = peripheral.wrap("left")
- modem.open(17)
- mod.open(3721)
- term.clear()
- term.setCursorPos(1,1)
- if fs.exists("disk/"..thisDoor) then
- local h = fs.open("disk/"..thisDoor, "r")
- pass = h.readAll()
- h.close()
- print("The passkey is: "..pass)
- else
- print("No such file!")
- end
- print("Listening to requests...")
- event , side , ch1 , ch2 , msg = os.pullEvent("modem_message")
- if side == "left" and msg == pass and ch1 == 17 then
- if permissionOP == "do" then
- rs(true)
- monReset()
- --mon.setTextColor(colours.green)
- mon.write("Open")
- sleep(5)
- monReset()
- --mon.setTextColor(colours.red)
- mon.write("Closed")
- rs(false)
- end
- elseif side == "bottom" and msg == "reboot" and ch1 == 3721 then
- shell.run("reboot")
- elseif side == "bottom" and msg == "lock" and ch1 == 3721 then
- permissionOP = "g"
- rs(false)
- elseif side == "bottom" and msg == "open" and ch1 == 3721 then
- permissionOP = "g"
- rs(true)
- elseif side == "bottom" and msg == "reset" and ch1 == 3721 then
- permissionOP = "do"
- rs(false)
- else
- print("fail")
- end
- shell.run("startup")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement