Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --sys2_service_doorTerminal
- os.loadAPI("sys/syslib")
- --syslib end
- local msgBefore = ""
- while true do
- shell.run("clear")
- if msgBefore ~= "" then print(msgBefore) end
- io.write("password:")
- local pwd = read("*")
- rednet.broadcast("@doorLock:password," .. pwd)
- local opened = false
- local closed = false
- local failed = false
- msgBefore = ""
- while (not opened or not closed) and not failed do
- local id, msg = syslib.receiveRednet()
- local tag, pts = syslib.getMsgData(msg)
- if tag == "@doorTerminal" then
- if pts[1] == "open" then
- opened = true
- print("door is open")
- elseif pts[1] == "closed" then
- if not opened then
- failed = true
- else
- closed = true
- end
- elseif pts[1] == "fail" then
- failed = true
- msgBefore = "wrong password"
- else print("unknown message: ", msg)
- end
- end
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement