funniray

Remote Turtle Installer

Sep 11th, 2016
137
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. files = {
  2.   {
  3.     file = "touchpoint",
  4.     pastebin = "pFHeia96",
  5.     friendly = "Touch Point",
  6.     side={"pocket","computer"}
  7.   },
  8.   {
  9.     file = "ender",
  10.     pastebin = "V91n5SXC",
  11.     friendly = "Ender CC"
  12.   },
  13.   {
  14.     file = "controller",
  15.     pastebin = "BFP5s115",
  16.     friendly = "The Controller Program",
  17.     side = {"pocket"},
  18.     startup = true
  19.   },
  20.   {
  21.     file = "controller",
  22.     pastebin = "FQX2J2wv",
  23.     friendly = "The recever program",
  24.     side = {"turtle"},
  25.     startup = true
  26.   }
  27. }
  28.  
  29. function download( pastebin, startup, filename )
  30.   if startup then
  31.     print("Would you like this to run on startup, or enter a file name")
  32.     lfilename = io.read()
  33.     if lfilename then
  34.       filename = lfilename
  35.     else
  36.       filename = "startup"
  37.     end
  38.   end
  39.   file = fs.open(filename,'w')
  40.   print("downloading "..filename.." from pastebin")
  41.   file.write(http.get("http://pastebin.com/raw/"..pastebin).readAll())
  42.   file.close()
  43. end
  44.  
  45. for k,v in pairs(files) do
  46.   if fs.exists(v.file) then
  47.     print(v.friendly.." is already on your computer, skipping download")
  48.   else
  49.     if v.side ~= nil then
  50.       if pocket then
  51.         for m,n in pairs(v.side) do
  52.           if n == "pocket" then
  53.             download(v.pastebin,v.startup,v.file)
  54.           end
  55.         end
  56.       elseif turtle then
  57.         for m,n in pairs(v.side) do
  58.           if n == "turtle" then
  59.             download(v.pastebin,v.startup,v.file)
  60.           end
  61.         end
  62.       else
  63.         for m,n in pairs(v.side) do
  64.           if n == "computer" then
  65.             download(v.pastebin,v.startup,v.file)
  66.           end
  67.         end
  68.       end
  69.     else
  70.       download(v.pastebin,v.startup,v.file)
  71.     end
  72.   end
  73. end
RAW Paste Data