Advertisement
osmarks

Doortronic Potatomatrix

Jul 29th, 2018
158
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.87 KB | None | 0 0
  1. local m = peripheral.find "modem"
  2. m.open(666)
  3.  
  4. local function download_table(url)
  5. return textutils.unserialise(http.get(url).readAll())
  6. end
  7.  
  8. local f = fs.open("door.txt", "r")
  9. local door_data = textutils.unserialise(f.readAll())
  10. local door_name = door_data.name
  11. local door_side = door_data.side
  12. f.close()
  13.  
  14. local function open_door()
  15. redstone.setOutput(door_side, true)
  16. sleep(2)
  17. redstone.setOutput(door_side, false)
  18. end
  19.  
  20. while true do
  21. local _, _, channel, reply_channel, message, distance = os.pullEvent "modem_message"
  22.  
  23. print("Message received", message)
  24.  
  25. local user = message
  26.  
  27. if distance < 5 then
  28. local auth_data = download_table "https://pastebin.com/raw/wyERqxtX"
  29. print(auth_data.users[user], auth_data.doors[door_name])
  30. if auth_data.users[user] and auth_data.users[user] >= auth_data.doors[door_name] then
  31. open_door()
  32. end
  33. end
  34. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement