The3vilM0nk3y

Updater

Nov 3rd, 2015
288
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.82 KB | None | 0 0
  1. args = {...}
  2. -- Config
  3. if args[1] then
  4.   fileName = args[1]
  5.   if args[2] then
  6.     location = "lua/" .. args[2]
  7.   else
  8.     location = "lua/"..args[1]
  9.   end
  10.   host = "http://wiki.evilcraft.net/"
  11.  
  12.   -- Do not Edit below this line
  13.   print("Updating " .. fileName)
  14.   link = host .. location
  15.   print("Downloading New File From\n" .. link)
  16.   data = http.get(link)
  17.   if data then
  18.     if fs.exists(fileName) then
  19.       print("Removing Old Data")
  20.       fs.delete(fileName)
  21.     end
  22.     file = fs.open(fileName,"w")
  23.     if file then
  24.       print("Saving Data")
  25.       file.write(data.readAll())
  26.       print("Update Completed")
  27.       file.close()
  28.     else
  29.       error("Could Not Create File " .. fileName)
  30.     end
  31.   else
  32.     print("Could Not Download File\n".. link)
  33.   end
  34. else
  35.   print("update filename [fileOnServer]")
  36. end
Advertisement
Add Comment
Please, Sign In to add comment