Advertisement
MarcusTheGamer

deleteDB.lua

Feb 19th, 2025 (edited)
83
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.26 KB | Gaming | 0 0
  1. function printSeperator()
  2.     print("---------------------------------------")
  3. end
  4.  
  5. local id = ...
  6.  
  7. local senderId,message,protocol = rednet.receive("DATA", 10)
  8.  
  9. if protocol == nil then
  10.     print("Attempt to receive data timed out")
  11.     printSeperator()
  12.     dofile("awaitRequest.lua")
  13. elseif protocol == "DATA" then
  14.     print("Successfully received data, creating file...")
  15. end
  16.  
  17. if not fs.exists("db/" .. senderId) then
  18.     print("No directory matching device ID (#" .. senderId .. ") found in database")
  19.     printSeperator()
  20.     dofile("awaitRequest.lua")
  21. end
  22.  
  23. if tostring(id) == tostring(senderId) then
  24.  
  25.     if not fs.exists("db/" .. senderId .. "/" .. message .. ".lua") then
  26.         print("No file matching name (#" .. message .. "lua" .. ") found in database")
  27.         printSeperator()
  28.         dofile("awaitRequest.lua")
  29.     end
  30.  
  31.     shell.run("delete", "db/" .. senderId .. "/" .. message .. ".lua")
  32.  
  33.     print("Succesfully removed file '" .. message .. ".lua' from database")
  34.     rednet.send(tonumber(id),"","SUCCESS")
  35.     printSeperator()
  36.     dofile("awaitRequest.lua")
  37. else
  38.     print("Error while establishing uplink, incorrect device ID, #" .. senderId .. " (Expected #" .. id .. ")")
  39.     printSeperator()
  40.     dofile("awaitRequest.lua")
  41. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement