Advertisement
Derek1017

Craftoid OS

May 24th, 2015
331
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.62 KB | None | 0 0
  1. shell.run("clear")
  2.  
  3. local booColor = false -- Create variable local to only the function
  4. if term.isColor ~= nil then -- Test to see if term.isColor even exists within ComputerCraft
  5. booColor = term.isColor() -- If it is then set the booColor to either true or false
  6. if booColor == false then
  7.      print("derekseitz's code detects this is a normal computer and installation will not start.") -- This will trigger if on a Stone Computer of the latest version
  8. else
  9.     print("derekseitz's code detects this is a color computer and installation will start.") -- This will trigger if on a Advanced Computer of the latest version
  10.     os.pullEvent()
  11.     term.setBackgroundColor(colors.blue)
  12.     term.clear()
  13.    
  14. root = "http://www.lozengia.com/tmas/Downloads/Minecraft/craftoid2/1.1/"
  15. print("Installing craftoid from:" .. root)
  16.  
  17. print("Defining Funtions")
  18. function setdir(directory)
  19.     if fs.exists(directory) == false then
  20.         fs.makeDir(directory)
  21.     end
  22. end
  23.  
  24. function downloadfile(file)
  25.     if fs.exists(file) then
  26.         fs.delete( file )
  27.     end
  28.    
  29.     local response = http.get(root .. file)
  30.     if response then
  31.         while response do
  32.             local sResponse = response.readAll()
  33.             response.close()
  34.             cache = shell.resolve( file )
  35.             local file = fs.open( cache, "w" )
  36.             file.write( sResponse )
  37.             file.close()
  38.             response = nil
  39.         end
  40.     end
  41. end
  42.  
  43. print("Defining files to install")
  44. directorys = { "installed", "sdcard", "sdcard/downloads" }
  45. files = { "startup", "craftoid.nfp", "craftoidOS", "dateAPI", "lockscreen.ico", "lockscreen.nfp", "settingscreen.nfp", "installed/missingicon.ico", "installed/adventure", "installed/adventure.ico", "installed/appstore", "installed/appstore.ico", "installed/ccTube", "installed/ccTube.ico", "installed/dj", "installed/dj.ico", "installed/edit", "installed/edit.ico", "installed/firebox", "installed/firebox.ico", "installed/html", "installed/html.ico", "installed/gps", "installed/gps.ico", "installed/html", "installed/html.ico", "installed/id", "installed/id.ico", "installed/paint", "installed/paint.ico", "installed/pastebin", "installed/pastebin.ico", "installed/shell", "installed/shell.ico", "installed/time", "installed/time.ico", "installed/worm", "installed/worm.ico" }
  46.  
  47. i = 1
  48. while directorys[i] do
  49.     print("Creating directory:" .. directorys[i])
  50.     setdir(directorys[i])
  51.     i=i+1
  52. end
  53. i = 1
  54. while files[i] do
  55.     print("Downloading File:" .. files[i])
  56.     downloadfile(files[i])
  57.     i=i+1
  58. end
  59.  
  60. print("Rebooting")
  61. shell.run("reboot")
  62.  
  63. end
  64. else
  65.      print("derekseitz's code detects this is a older version and installation will not start.") -- This will trigger if on a Stone Computer of the latest version
  66. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement