Guest User

COMPZANQUALDATA

a guest
Mar 4th, 2017
93
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 9.15 KB | None | 0 0
  1. -- Clear screen
  2. term.setBackgroundColor(colors.black)
  3. term.clear()
  4. term.setCursorPos(1,1)
  5. print("Extracting Zanqual API v0.3\nby DaloDaloDalo/XxCubegamerxX")
  6. sleep(1)
  7.  
  8. -- If isn't installed
  9. if not fs.exists("/ZanqualScript") then
  10.  
  11.   -- Reading function
  12.   local function w_r(path,from,to,insertTo)
  13.     local file = fs.open(path,"r")
  14.     local outputRaw = {}
  15.     local output = {}
  16.     local text = ""
  17.     for line in file.readLine do
  18.       outputRaw[#outputRaw+1] = line
  19.     end
  20.     for i = from, to do
  21.       output[#output+1] = outputRaw[i]
  22.     end
  23.     file.close()
  24.     local file = fs.open(insertTo,"w")
  25.     for _,line in pairs(output) do
  26.       text = text..line.."\n"
  27.     end
  28.     file.write(text)
  29.     file.close()
  30.   end
  31.  
  32.   -- Extracting files
  33.   local this = shell.getRunningProgram()
  34.   w_r(this,77,315,"ZanqualScript/Zanqual")
  35.   w_r(this,318,337,"ZanqualScript/Zanqual_API_Loader")
  36.   w_r(this,340,345,"ZanqualScript/Zanqual_API_Loader_Startup")
  37.   w_r(this,348,375,"changelog")
  38.  
  39.   -- Print successfully installed
  40.   print([[
  41.  
  42.   Successfully extracted Zanqual Script
  43.   Rebooting to install in 3 seconds
  44.   ]])
  45.   sleep(3)
  46.   oldReboot = os.reboot
  47.   oldShutd = os.shutdown
  48.   os.reboot = function()
  49.     if fs.exists("startup") then
  50.       fs.move("startup","startupBackup")
  51.     end
  52.     fs.copy("ZanqualScript/Zanqual_API_Loader_Startup","startup")
  53.     oldReboot()
  54.   end
  55.   os.reboot()
  56.  
  57. -- If is installed
  58. else
  59.  
  60.   -- Print already installed
  61.   print([[
  62.  
  63.   Already installed Zanqual Script
  64.   Press any key to exit
  65.   ]])
  66. end
  67.  
  68. -- Waits for any key
  69. os.pullEventRaw("key")
  70. term.clear()
  71. term.setCursorPos(1,1)
  72.  
  73. --[[
  74.  
  75.  
  76. ZANQUAL:
  77. --## Zanqual API v0.4 COPYRIGHT (c) ##--
  78. --## by DaloDaloDalo/XxCubegamerxX ##--
  79.  
  80. function p(text) return print(text) end
  81. function scp(x,y) return term.setCursorPos(x,y) end
  82. function stc(clr) return term.setTextColor(clr) end
  83. function sbc(clr) return term.setBackgroundColor(clr) end
  84. function c() return term.clear() end
  85. function cl() return term.clearLine() end
  86. function w(text) return write(text) end
  87.  
  88. function rednet.checkModem()
  89.   for n,sModem in ipairs(peripheral.getNames()) do
  90.     if peripheral.getType(sModem) == "modem" then
  91.       return sModem
  92.     end
  93.   end
  94.   return false
  95. end
  96.  
  97. local oldTostring = tostring
  98. tostring = function(numberTable,more)
  99.   if type(numberTable) == "table" then
  100.     local extractedText = ""
  101.     if not more then
  102.       more = " "
  103.     end
  104.     for _,tableExtract in pairs(numberTable) do
  105.       extractedText = extractedText..tableExtract..more
  106.     end
  107.     return extractedText
  108.   else
  109.     return oldTostring(numberTable)
  110.   end
  111. end
  112.  
  113. local function rednetAll(var)
  114.   local output = 0
  115.   for n,sModem in ipairs(peripheral.getNames()) do
  116.     if peripheral.getType(sModem) == "modem" then
  117.       if not rednet.isOpen(sModem) then
  118.         output = output+1
  119.         if var == "open" then
  120.           rednet.open(sModem)
  121.         elseif var == "close" then
  122.           rednet.close(sModem)
  123.         end
  124.       end
  125.     end
  126.   end
  127.   if output == 0 then
  128.     return false
  129.   end
  130.   return output
  131. end
  132.  
  133. function rednet.openAll() return rednetAll("open") end
  134. function rednet.closeAll() return rednetAll("close") end
  135.  
  136. function colors.random()
  137.   local colorTable4Bit = {1,2,4,8,16,32,64,128,256,512,1024,2048,4096,8192,16384,32768}
  138.   local colorTable2Bit = {1,128,256,32768}
  139.   if term.isColor() then
  140.     return colorTable4Bit[math.random(1,16)]
  141.   end
  142.   return colorTable2Bit[math.random(1,4)]
  143. end
  144.  
  145. function textutils.delayWrite(text,delay)
  146.   if type(text) ~= "string" or type(delay) ~= "number" then
  147.     error("string,number expected.")
  148.   end
  149.   for stringSub = 1, string.len(text) do
  150.     write(string.sub(text,stringSub,stringSub))
  151.     sleep(delay)
  152.   end
  153. end
  154.  
  155. function colors.getTable()
  156.   if term.isColor() then
  157.     return {1,2,4,8,16,32,64,128,256,512,1024,2048,4096,8192,16384,32768}
  158.   end
  159.   return {1,128,256,32768}
  160. end
  161.  
  162. function textutils.delayPrint(text,delay)
  163.   textutils.delayWrite(text,delay)
  164.   print("")
  165. end
  166.  
  167. function string.random(nStringLen)
  168.   if type(nStringLen) ~= "number" then
  169.     error("number expected.")
  170.   end
  171.   local aviableChars = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890@|\\/%&()=?}][{´`'#*~+,.-;:_<>^°\"$!"
  172.   local output = ""
  173.   for returnOutput = 1, nStringLen do
  174.     subRandom = math.random(1,string.len(aviableChars))
  175.     output = output..string.sub(aviableChars,subRandom,subRandom)
  176.   end
  177.   return output
  178. end
  179.  
  180. function fs.write(path,text)
  181.   if type(path) ~= "string" or type(text) ~= "string" then
  182.     error("string,string expected.")
  183.   end
  184.   local file = assert(fs.open(path,"w"))
  185.   file.write(text)
  186.   file.close()
  187. end
  188.  
  189. function fs.writeFromTable(path,t)
  190.   if type(path) ~= "string" or type(t) ~= "table" then
  191.     error("string,table expected.")
  192.   end
  193.   fs.write(path,tostring(t,"\n"))
  194. end
  195.  
  196. function fs.getLine(path,ln)
  197.   if type(path) ~= "string" or type(ln) ~= "number" then
  198.     error("string,number expected.")
  199.   end
  200.   if not fs.exists(path) then
  201.     error("file "..path.." doesn't exist.")
  202.   end
  203.   local file = fs.open(path,"r")
  204.   return file.readLine(ln)
  205. end
  206.  
  207. function fs.getTable(path)
  208.   if type(path) ~= "string" then
  209.     error("string expected.")
  210.   end
  211.   if not fs.exists(path) then
  212.     error("file "..path.." doesn't exist.")
  213.   end
  214.   local file = fs.open(path,"r")
  215.   local nLine = 1
  216.   local lines = {}
  217.   local line = file.readLine("*1")
  218.   while line ~= nil do
  219.     lines[nLine] = line
  220.     nLine = nLine+1
  221.     line = file.readLine("*1")
  222.   end
  223.   return lines
  224. end
  225.  
  226. function fs.getString(path)
  227.   if type(path) ~= "string" then
  228.     error("string expected.")
  229.   end
  230.   if not fs.exists(path) then
  231.     error("file "..path.." doesn't exist.")
  232.   end
  233.   local file = fs.open(path,"r")
  234.   return file.readAll()
  235. end
  236.  
  237. function fs.replaceLine(path,ln,text)
  238.   if type(path) ~= "string" or type(ln) ~= "number" or type(text) ~= "string" then
  239.     error("string,number,string expected.")
  240.   end
  241.   if not fs.exists(path) then
  242.     error("file "..path.." doesn't exists")
  243.   end
  244.   local lines = fs.getTable(path)
  245.   lines[ln] = text
  246.   fs.writeFromTable(path,lines)
  247. end
  248.  
  249. function fs.append(path,text)
  250.   if type(path) ~= "string" or type(path) ~= "string" then
  251.     error("string,string expected.")
  252.   end
  253.   if not fs.exists(path) then
  254.     error("file "..path.." doesn't exist.")
  255.   end
  256.   local file = assert(fs.open(path,"a"))
  257.   file.write(text)
  258.   file.close()
  259. end
  260.  
  261. local oldWrite = write
  262. write = function(s)
  263.   local toggle = 0
  264.   for i = 1, string.len(s) do
  265.     if toggle == 0 then
  266.       local ccv = string.sub(s,i,i+3)
  267.       if string.sub(s,i,i) == "#" and string.sub(s,i+3,i+3) then
  268.         toggle = 3
  269.       else
  270.         oldWrite(string.sub(s,i,i))
  271.       end
  272.       if ccv == "#wh#" then
  273.         stc(1)
  274.       elseif ccv == "#or#" then
  275.         stc(2)
  276.       elseif ccv == "#ma#" then
  277.         stc(4)
  278.       elseif ccv == "#lb#" then
  279.         stc(8)
  280.       elseif ccv == "#ye#" then
  281.         stc(16)
  282.       elseif ccv == "#li#" then
  283.         stc(32)
  284.       elseif ccv == "#pi#" then
  285.         stc(64)
  286.       elseif ccv == "#gy#" then
  287.         stc(128)
  288.       elseif ccv == "#lg#" then
  289.         stc(256)
  290.       elseif ccv == "#cy#" then
  291.         stc(512)
  292.       elseif ccv == "#pu#" then
  293.         stc(1024)
  294.       elseif ccv == "#bl#" then
  295.         stc(2048)
  296.       elseif ccv == "#br#" then
  297.         stc(4096)
  298.       elseif ccv == "#gr#" then
  299.         stc(8192)
  300.       elseif ccv == "#re#" then
  301.         stc(16384)
  302.       elseif ccv == "#bl#" then
  303.         stc(32768)
  304.       elseif ccv == "#ra#" then
  305.         stc(colors.random())
  306.       end
  307.     else
  308.       toggle = toggle-1
  309.     end
  310.   end
  311. end
  312.  
  313. print = function(s)
  314.   return write(s.."\n")
  315. end
  316.  
  317. ZANQUAL API LOADER:
  318. local oldShutd = os.shutdown
  319. local oldReboot = os.reboot
  320.  
  321. local function rgm()
  322.   if fs.exists("startup") then
  323.     fs.copy("startup","startupBackup")
  324.     fs.delete("startup")
  325.   end
  326.   fs.copy("ZanqualScript/Zanqual_API_Loader_Startup","startup")
  327. end
  328.  
  329. os.shutdown = function()
  330.   rgm()
  331.   oldShutd()
  332. end
  333.  
  334. os.reboot = function()
  335.   rgm()
  336.   oldReboot()
  337. end
  338.  
  339. ZANQUAL API LOADER STARTUP:
  340. fs.delete("startup")
  341. if fs.exists("startupBackup") then
  342.   fs.move("startupBackup","startup")
  343. end
  344. shell.run("ZanqualScript/Zanqual_API_Loader")
  345. shell.run("ZanqualScript/Zanqual")
  346.  
  347. ZANQUAL CHANGELOG:
  348.  
  349. New stuff added (removed from) to Zanqual v0.4:
  350.  
  351.  
  352. + added shortcut-functions:
  353.  
  354.     none
  355.  
  356. + added new functions:
  357.  
  358.     string.random(lenght) - Returns a random generated string with any english letters,numbers and symbols.
  359.  
  360. + modified functions:
  361.  
  362.     write(string) - Now can change into any color without using term.setTextColor(...):
  363.         #wh# = white, #or# = orange, #ma# = magenta, #lb# = light blue, #ye# = yellow, #li# = lime, #pi# = pink, #gy# = gray,
  364.         #lg# = light gray, #cy# = cyan, #pu# = purple, #bl# = blue, #br# = brown, #gr# = green, #re# = red, #bl# = black, #ra# = random color
  365.     print(string) - Does the same like write(...) but writes "\n" at the end.
  366.    
  367. ~ changed stuff:
  368.  
  369.     fixed string.random(...):
  370.         I, the spoon, forgot to place a type(...) at the non-number detector! :/
  371.  
  372. - removed
  373.    
  374.     nothing
  375.  
  376. --]]
Add Comment
Please, Sign In to add comment