Left4Cake2

Craftmon Installer

Nov 19th, 2013
455
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.50 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("TrinaryAtom 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("TrinaryAtom 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/Cmon/2/"
  15. print("Installing Craftmon 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 Game Directorys to install")
  44. directorys = { "Craftmon", "Craftmon/mon" }
  45. print("Defining Game files to install")
  46. mainGame = { "Cmon", "Craftmon/battlebackground.nfp" }
  47. print("Defining Cmon to Download")
  48. CmonDirectorys = { "Blastoise", "Bulbasaur", "Charizard", "Charmander", "Charmeleon", "Creeper", "Ivysaur", "MissingNo", "Squirtle", "Venusaur", "Wartortle" }
  49.  
  50.  
  51.  
  52. i = 1
  53. while directorys[i] do
  54.     print("Creating directory:" .. directorys[i])
  55.     setdir(directorys[i])
  56.     i=i+1
  57. end
  58.  
  59. i = 1
  60. while mainGame[i] do
  61.     print("Downloading File:" .. mainGame[i])
  62.     downloadfile(mainGame[i])
  63.     i=i+1
  64. end
  65.  
  66. i = 1
  67. while CmonDirectorys[i] do
  68.     print("Downloading Cmon:" .. CmonDirectorys[i])
  69.     setdir("Craftmon/mon/" .. CmonDirectorys[i])
  70.     downloadfile("Craftmon/mon/" .. CmonDirectorys[i] .. "/front.nfp")
  71.     downloadfile("Craftmon/mon/" .. CmonDirectorys[i] .. "/back.nfp")
  72.     downloadfile("Craftmon/mon/" .. CmonDirectorys[i] .. "/Stats")
  73.     i=i+1
  74. end
  75.  
  76.  
  77. print("Clearing")
  78. shell.run("clear")
  79.  
  80. end
  81. else
  82.      print("TrinaryAtom code detects this is an older version of Computercraft and installation will not start.") -- This will trigger if on a Stone Computer of the latest version
  83. end
Advertisement
Add Comment
Please, Sign In to add comment