t8rt0t

fern-scanner-updater.lua

May 18th, 2024 (edited)
243
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.00 KB | None | 0 0
  1. --Pastebin updater for the fern scanner
  2. fs.delete("downloads")
  3. shell.openTab("sh")
  4. local files = {
  5.     {"MWY8mf12","startup.lua",false},
  6.     {"mmcNfuBr","fern-data.lua",false},
  7.     {"yTARGS6A","fern-scanner.lua",true}
  8. }
  9.  
  10. --Clears out comments and whitespace
  11. local function saveSpace(path)
  12.     if not fs.exists(path) or fs.isDir(path) then return false end
  13.     local file = fs.open(path,"r")
  14.     local data = file.readAll()
  15.     file.close()
  16.     data = data:gsub("%-%-.-\n","\n") --removes comments
  17.     data = data:gsub("%s*\n%s*","\n")
  18.     return data  
  19. end
  20. local function update(pstbnCode,fileName,run,...)
  21.     shell.run("pastebin get "..pstbnCode .. " /downloads/" .. fileName)
  22.     local file = fs.open(fileName,"w+")
  23.     file.write(saveSpace("/downloads/"..fileName))
  24.     file.close()
  25.     fs.delete("downloads")
  26.     local args = {...}
  27.     if run then pcall(function() shell.run(fileName,unpack(args))end) end
  28. end
  29.  
  30. for k,v in pairs(files) do
  31.     update(unpack(v))
  32. end
  33.  
  34.  
  35. sleep(5)
  36. os.reboot()
Advertisement
Add Comment
Please, Sign In to add comment