SHARE
TWEET

SimSoft-SappS-Installer (template; english)

Simlor_GER Mar 5th, 2016 (edited) 292 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. --App Installer - by LDDestroier and SimlorLP
  2. --Free for use and modification
  3.  
  4. local pF = {
  5.   name = "Example",                            --name of executed program
  6.   folder = "exampleFolder",                    --folder of executed program and other files
  7.   colorCode = 1,                               --number code of icon, 1-20 currently (http://simsoft-en.jimdo.com/for-developers)
  8.   liveSystem = "",                             --enables livesystem file
  9.   files = {                                    --names and pasteIDs of all files. allows directories too
  10.         ["Example"] = "pasteID",               --make SURE to make one entry the same as 'name', or else it won't execute anything
  11.         ["cfg/exampleAPI"] = "anotherPasteID"  --this works
  12.   }
  13. }
  14.  
  15. local getFromPastebin = function(code,path)
  16. if not type(code) == "string" then
  17.   error("Expected pastebin code")
  18. elseif not type(path) == "string" then
  19.   error("Expected file path")
  20. end
  21. local prog = http.get("http://pastebin.com/raw/"..code)
  22. if not code then
  23.   return false, "could not connect"
  24. end
  25. prog = prog.readAll()
  26. if fs.exists(fs.getName(path)) and not fs.isDir(fs.getName(path)) then
  27.   return false, "file exists in that path"
  28. end
  29. if not fs.exists(fs.getDir(path)) then
  30.   fs.makeDir(fs.getDir(path))
  31. end
  32. local file = fs.open(path,"w")
  33. file.write(prog)
  34. file.close()
  35. return true, fs.getSize(path)
  36. end
  37.  
  38. function appInstaller(name,farbe,ver,loesch,LiveJaNein,LivePfad)
  39. term.setBackgroundColor(128)
  40. term.setTextColor(1)
  41. term.clear()
  42. print("Starting installation...")
  43. --Absicherung
  44. local file = fs.open("SimSoft/Daten/SappS/A","r")
  45. local fileData = {}
  46. local line = file.readLine()
  47. repeat
  48.   table.insert(fileData,line)
  49.   line = file.readLine()
  50. until line == nil
  51. file.close()
  52. anz = tonumber(fileData[1])
  53. if anz >= 15 then
  54.   print("App limit has been reached! Delete one to make space. Sorry.")
  55.   sleep(0.4)
  56.   return
  57. else
  58.   anz = (anz+1)
  59.   local file = fs.open("SimSoft/Daten/SappS/A","w")
  60.   file.write(anz)
  61.   file.close()
  62.   local file = fs.open("SimSoft/Daten/SappS/"..anz,"w")
  63.   file.writeLine(name)
  64.   file.writeLine(anz)
  65.   file.writeLine(farbe.."\n")
  66.   file.writeLine(ver)
  67.   file.writeLine(loesch)
  68.   if LiveJaNein ~= "" then
  69.    file.writeLine("t")
  70.    file.writeLine(LiveJaNein)
  71.   else
  72.    file.writeLine("f\n")
  73.   end
  74.   file.close()
  75. end
  76. end
  77. for k,v in pairs(pF.files) do
  78. getFromPastebin(v,fs.combine(fs.combine("SimSoft/SappS",pF.folder),k))
  79. end
  80. appInstaller(string.sub(pF.name,1,6),tostring(pF.colorCode)..".0",fs.combine(pF.folder,pF.name),pF.folder,pF.liveSystem)
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Top