Advertisement
onwardprogress

functionTest

Jan 2nd, 2023 (edited)
857
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.77 KB | None | 0 0
  1. function checkDisk()
  2.     local result = false
  3.     if disk.isPresent("left") or disk.isPresent("right") then
  4.         result = true
  5.     end
  6.     return result
  7. end
  8.  
  9. print("Please insert a disk into the drive")
  10. while true do
  11.     local event, diskSide = os.pullEvent("disk")
  12.     if checkDisk() then
  13.         local mountPath = disk.getMountPath(diskSide)
  14.         if fs.exists(mountPath .. "/user_id.txt") then
  15.             print("Found user_id.txt")
  16.             print("Found at " .. mountPath)
  17.             local file = fs.open(mountPath .. "/user_id.txt", "r")
  18.             -- Read the contents of the file
  19.             local admin_user_id = file.readAll()
  20.             -- Close the file
  21.             file.close()
  22.         else
  23.             print("user_id.txt not found")
  24.         end
  25.         break
  26.     end
  27.     sleep(3)
  28. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement