Advertisement
Guest User

Quick Install Patch

a guest
Jan 24th, 2015
175
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. local ver = 1.0.2 - Clunker5 Patched
  2. local progName = "Random"
  3.  
  4. local bProblem = false
  5.  
  6. local function varifing()
  7.     local sParth = shell.getRunningProgram()
  8.         print("Parth:"..sParth)
  9.     if fs.getName(sParth) == "startup" then
  10.         local sDir = string.sub(sParth,1,#sParth-8)
  11.         print("Disk: "..sDir)
  12.         if fs.exists(sDir..[[\]].."install") then
  13.             print("Found Install folder")
  14.             file = io.open(sDir..[[\]].."install"..[[\]].."LIST","r")
  15.             local tInstruction = {}
  16.             local last = file:read()
  17.             repeat
  18.                 table.insert(tInstruction,last)
  19.                 last = file:read()
  20.                 print(last)
  21.             until last == nil
  22.             file:close()
  23.             -- check that files are avalible
  24.             local tNames = {}
  25.             local tParths = {}
  26.             print("Cheking LIST :")
  27.             local termX,termY = term.getCursorPos()
  28.             for i = 1,#tInstruction do
  29.                 term.setCursorPos(termX,termY)
  30.                 term.clearLine()
  31.                 write("Completed: "..tostring((100/#tInstruction)*i)..[[ %]])
  32.                
  33.                 if math.fmod(i,2) == 1 then -- odd number
  34.                     table.insert(tNames,tInstruction[i])
  35.                 else -- even number
  36.                     table.insert(tParths,tInstruction[i])
  37.                 end
  38.             end
  39.             local proceed = true
  40.             for i = 1,#tNames do
  41.                 if fs.exists(sDir..[[\]].."install"..[[\]]..tNames[i]) then
  42.                 else
  43.                     proceed = false
  44.                 end
  45.             end
  46.             if #tNames == #tParths then
  47.                
  48.             else
  49.                 proceed = false
  50.             end
  51.             if proceed then
  52.                 --local tFileList = fs.list(sDir..[[\]].."install")
  53.                 print("\nInstalling ...")
  54.                 termX,termY = term.getCursorPos()
  55.                 for i = 1,#tNames do
  56.                     term.setCursorPos(termX,termY)
  57.                     term.clearLine()
  58.                     write("Completed: "..tostring((100/#tNames)*i)..[[ %]])
  59.                     local temp = tParths[i] -- ..[[\]]..tNames[i]
  60.                     if fs.exists(temp) then -- fs.delete
  61.                         fs.delete(temp)
  62.                     end
  63.                     local temp2 = string.sub(temp,1,#temp - (string.len(fs.getName(temp))+1))
  64.                     if fs.isDir(temp2) then
  65.                        
  66.                     else
  67.                         fs.makeDir(temp2)
  68.                     end
  69.                     fs.copy(sDir..[[\]].."install"..[[\]]..tNames[i],tParths[i])
  70.                 end
  71.                 print("\nInstall Completed")
  72.             else
  73.                 print("[ERROR] installer varification failed")
  74.             end
  75.         else
  76.             print("ERROR")
  77.         end
  78.     end
  79. end
  80.  
  81. while true do
  82.     term.clear()
  83.     term.setCursorPos(1,1)
  84.     print("Welcom to Quick Install ver: "..ver)
  85.     print("[WARNING] Will override existing Files")
  86.     if bProblem then
  87.         print("Please select y Y n or N ")
  88.         bProblem = false
  89.     end
  90.     write("Do you want to install "..progName..[[ Y/N ]])
  91.     local selection = string.lower(read())
  92.     if selection == "y" then
  93.         print("varifing Install")
  94.         varifing()
  95.         break
  96.     elseif selection == "n" then
  97.         print("Install aborted")
  98.         break
  99.     else
  100.         bProblem = true
  101.     end
  102. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement