Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local m = peripheral.find "modem"
- m.open(666)
- local function download_table(url)
- return textutils.unserialise(http.get(url).readAll())
- end
- local f = fs.open("door.txt", "r")
- local door_data = textutils.unserialise(f.readAll())
- local door_name = door_data.name
- local door_side = door_data.side
- f.close()
- local function open_door()
- redstone.setOutput(door_side, true)
- sleep(2)
- redstone.setOutput(door_side, false)
- end
- while true do
- local _, _, channel, reply_channel, message, distance = os.pullEvent "modem_message"
- print("Message received", message)
- local user = message
- if distance < 5 then
- local auth_data = download_table "https://pastebin.com/raw/wyERqxtX"
- print(auth_data.users[user], auth_data.doors[door_name])
- if auth_data.users[user] and auth_data.users[user] >= auth_data.doors[door_name] then
- open_door()
- end
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement