Jebula999

Script Loader

Jun 26th, 2019 (edited)
197
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. local initScriptID = "Bp4bQJb7"
  2. local scripts = {}
  3.  
  4.  
  5. scripts["iPW77diY"] = "miner"
  6.  
  7.  
  8. local args = {...}
  9.  
  10. function loadScript(code, name)
  11.     if fs.exists(name) == true then
  12.         shell.run("rm", name)
  13.     end
  14.     shell.run("pastebin","get",code,name)
  15. end
  16.  
  17. if args[1] == "get" then
  18.  
  19.     if args[2] ~= nil then
  20.         found = false
  21.         for code, name in pairs(scripts) do
  22.             if name == args[2] then
  23.                 found = true
  24.                 term.clear()
  25.                 term.setCursorPos(0,0)
  26.                 print("\nLoading Script ["..name.."]")
  27.                 pcall(loadScript, code, name)
  28.                 break
  29.             end
  30.         end
  31.         if not found then
  32.             print("\nFailed to load script ["..name.."]")
  33.             return
  34.         end
  35.     else
  36.         local progress = 0
  37.         local qty = table.getn(scripts)
  38.         for code, name in pairs(scripts) do
  39.             term.clear()
  40.             term.setCursorPos(0,0)
  41.             print("\nLoading Scripts: [ "..progress.." of "..qty.." ]")
  42.             pcall(loadScript, code, name)
  43.             progress = progress + 1
  44.         end
  45.     end
  46.  
  47.     os.reboot()
  48. else
  49.     term.clear()
  50.     term.setCursorPos(0,0)
  51.     print("\nUpdating Self ...")
  52.  
  53.     pcall(loadScript, initScriptID, "init")
  54.     shell.run("init", "get")
  55. end
Add Comment
Please, Sign In to add comment