tom759345

EnergyReader 2.0

Sep 26th, 2014
1,737
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.88 KB | None | 0 0
  1. if fs.exists("DEV") then
  2.     Database = "https://www.dropbox.com/sh/562255sfecqvcmd/AADFwuoDxAF5SOJfNIt4kdg9a?dl=0"
  3. else
  4.     Database = "https://www.dropbox.com/sh/atqanyavuxjs6tz/AAAc7FqXPVB9UAw4N7NjbzEMa?dl=0"
  5. end
  6.  
  7. local ProgramName =
  8.     "Tom's RF Reader 2.0"
  9.  
  10. local pastebincode =
  11.     "C45iaMup"
  12.  
  13. local DownloadLink =
  14.     tostring(Database)
  15.  
  16. local supVersion = {
  17.     "CraftOS 1.5"
  18. }
  19.    
  20.    
  21. DownloadNames = {
  22.     "startup",
  23.     "p",
  24.     "var",
  25.     "EbOS_Concept",
  26.     "EnergyReader",
  27.     "FAQ",
  28.     "Installer",
  29.     "updater",
  30.     "version"
  31.  }
  32.  
  33. PackFile =
  34.     "TRFR2.insl"
  35.  
  36. local function ChangeColor(color)
  37.     term.setBackgroundColor(color)
  38.     term.setTextColor(color)
  39. end
  40.  
  41. if fs.exists("unpack") == false then
  42.     print("This program requires an unpacking program.")
  43.     print("It will be downloaded and installed on you computer now")
  44.     shell.run("pastebin","get",pastebincode, "unpack")
  45.     sleep(2)
  46. end
  47.  
  48. term.setTextColor(colors.red)
  49. term.clear()
  50. term.setCursorPos(1,1)
  51. print("Current version: "..os.version())
  52. print(" ")
  53. print("A warning message should appear. If not, you are running a version on CraftOS that this porgram is not yet tested for! Any bugs or crashes will happend on own risk!")
  54. print(" ")
  55. if supVersion[1] == os.version() then
  56.     print("WARNING! Make sure your http api is enabled befor starting this installation!")
  57. end
  58. if supVersion[2] == os.version() then
  59.     print("WARNING! Make sure that http whitelist is disabled or add Dropbox.com to the whitelist!")
  60. end
  61. print("Press Y to start the installation")
  62. e, k = os.pullEvent("key")
  63. if k ~= 21 then
  64.     print(":)")
  65.     sleep(1)
  66.     os.shutdown()
  67. end
  68.  
  69. term.setBackgroundColor(colors.blue)
  70. term.setTextColor(colors.white)
  71. term.clear()
  72. term.setCursorPos(1,1)
  73. term.write("Installer for "..ProgramName)
  74.  
  75. fs.makeDir(PackFile)
  76.  
  77. for i = 1,#DownloadNames do
  78.     ChangeColor(colors.gray)
  79.     term.setCursorPos(15,5)
  80.     term.write("XXXXXXXXXXXXXXXXXXXX")
  81.     ChangeColor(colors.lightGray)
  82.     for i=6,12 do
  83.         term.setCursorPos(15,i)
  84.         term.write("XXXXXXXXXXXXXXXXXXXX")
  85.     end
  86.     term.setTextColor(colors.black)
  87.     term.setCursorPos(16,7)
  88.     term.write("Installing...")
  89.     term.setCursorPos(17,8)
  90.     term.write(DownloadNames[i])
  91.     term.setCursorPos(16,10)
  92.     term.setBackgroundColor(colors.gray)
  93.     for x = 1,#DownloadNames do
  94.         term.write(" ")
  95.     end
  96.    
  97.     term.setCursorPos(16,10)
  98.     term.setBackgroundColor(colors.green)
  99.     for c = 1,i do
  100.         term.write(" ")
  101.     end
  102.     Download = http.get(DownloadLink.."/"..DownloadNames[i])
  103.     d = fs.open(PackFile.."/"..DownloadNames[i],"w")
  104.     d.write(Download.readAll())
  105.     d.close()
  106. end
  107.  
  108. term.setBackgroundColor(colors.lightGray)
  109. term.setTextColor(colors.black)
  110. term.setCursorPos(16,11)
  111. term.write("Done")
  112.  
  113. term.setCursorPos(16,12)
  114. term.setBackgroundColor(colors.black)
  115. term.setTextColor(colors.white)
  116. shell.run("unpack",PackFile)
  117.  
  118. term.setBackgroundColor(colors.lightGray)
  119. term.setTextColor(colors.black)
  120. write(" Success!")
  121. sleep(2)
  122. os.reboot()
Advertisement
Add Comment
Please, Sign In to add comment