Advertisement
MarcusTheGamer

uploadDB.lua

Feb 19th, 2025 (edited)
85
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.99 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.     fs.makeDir("db/" .. senderId)
  19. end
  20.  
  21. if tostring(id) == tostring(senderId) then
  22.     local file = fs.open("db/" .. senderId .. "/" .. message[1] .. ".lua", "w")
  23.     file.write(message[2])
  24.     file.close()
  25.      
  26.     print("Succesfully created file '" .. message[1] .. ".lua' in database")
  27.     rednet.send(tonumber(id),"","SUCCESS")
  28.     printSeperator()
  29.     dofile("awaitRequest.lua")
  30. else
  31.     print("Error while establishing uplink, incorrect device ID, #" .. senderId .. " (Expected #" .. id .. ")")
  32.     printSeperator()
  33.     dofile("awaitRequest.lua")
  34. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement