Left4Cake2

Craftmon Installer V3

Nov 20th, 2013
518
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.94 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/3/"
  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", "Craftmon/attack" }
  45. print("Defining Cmon Directorys to install")
  46. CmonDirectorys = { "Blastoise", "Bulbasaur", "Charizard", "Charmander", "Charmeleon", "Creeper", "Ivysaur", "MissingNo", "Squirtle", "Venusaur", "Wartortle" }
  47. attackfiles = { "Bite", "BugBite", "BugBuzz", "DragonRage", "Ember", "FireBlast", "Flamethrower", "Growl", "Gust", "Harder", "HydroPump", "Psychic", "RazorLeaf", "Scratch", "Slash", "StringShot", "Synthesis", "Tackel", "TailWhip", "TakeDown", "VineWhip", "WaterGun", "WaterPulse", "WingAttack"}
  48. print("Defining Game files to install")
  49. mainGame = { "Cmon", "Craftmon/battlebackground.nfp" }
  50.  
  51. i = 1
  52. while directorys[i] do
  53.     print("Creating directory:" .. directorys[i])
  54.     setdir(directorys[i])
  55.     i=i+1
  56. end
  57.  
  58. i = 1
  59. while mainGame[i] do
  60.     print("Downloading File:" .. mainGame[i])
  61.     downloadfile(mainGame[i])
  62.     i=i+1
  63. end
  64.  
  65. i = 1
  66. while CmonDirectorys[i] do
  67.     print("Downloading Cmon:" .. CmonDirectorys[i])
  68.     setdir("Craftmon/mon/" .. CmonDirectorys[i])
  69.     downloadfile("Craftmon/mon/" .. CmonDirectorys[i] .. "/front.nfp")
  70.     downloadfile("Craftmon/mon/" .. CmonDirectorys[i] .. "/back.nfp")
  71.     downloadfile("Craftmon/mon/" .. CmonDirectorys[i] .. "/Stats")
  72.     i=i+1
  73. end
  74.  
  75. i = 1
  76. while attackfiles[i] do
  77.     print("Downloading Cmon:" .. attackfiles[i])
  78.     downloadfile("Craftmon/attack/" .. attackfiles[i])
  79.     i=i+1
  80. end
  81.  
  82. print("Rebooting")
  83. shell.run("reboot")
  84.  
  85. end
  86. else
  87.      print("TrinaryAtom code detects this is a older version and installation will not start.") -- This will trigger if on a Stone Computer of the latest version
  88. end
Advertisement
Add Comment
Please, Sign In to add comment