Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- Clear screen
- term.setBackgroundColor(colors.black)
- term.clear()
- term.setCursorPos(1,1)
- print("Extracting Zanqual API v0.3\nby DaloDaloDalo/XxCubegamerxX")
- sleep(1)
- -- If isn't installed
- if not fs.exists("/ZanqualScript") then
- -- Reading function
- local function w_r(path,from,to,insertTo)
- local file = fs.open(path,"r")
- local outputRaw = {}
- local output = {}
- local text = ""
- for line in file.readLine do
- outputRaw[#outputRaw+1] = line
- end
- for i = from, to do
- output[#output+1] = outputRaw[i]
- end
- file.close()
- local file = fs.open(insertTo,"w")
- for _,line in pairs(output) do
- text = text..line.."\n"
- end
- file.write(text)
- file.close()
- end
- -- Extracting files
- local this = shell.getRunningProgram()
- w_r(this,77,315,"ZanqualScript/Zanqual")
- w_r(this,318,337,"ZanqualScript/Zanqual_API_Loader")
- w_r(this,340,345,"ZanqualScript/Zanqual_API_Loader_Startup")
- w_r(this,348,375,"changelog")
- -- Print successfully installed
- print([[
- Successfully extracted Zanqual Script
- Rebooting to install in 3 seconds
- ]])
- sleep(3)
- oldReboot = os.reboot
- oldShutd = os.shutdown
- os.reboot = function()
- if fs.exists("startup") then
- fs.move("startup","startupBackup")
- end
- fs.copy("ZanqualScript/Zanqual_API_Loader_Startup","startup")
- oldReboot()
- end
- os.reboot()
- -- If is installed
- else
- -- Print already installed
- print([[
- Already installed Zanqual Script
- Press any key to exit
- ]])
- end
- -- Waits for any key
- os.pullEventRaw("key")
- term.clear()
- term.setCursorPos(1,1)
- --[[
- ZANQUAL:
- --## Zanqual API v0.4 COPYRIGHT (c) ##--
- --## by DaloDaloDalo/XxCubegamerxX ##--
- function p(text) return print(text) end
- function scp(x,y) return term.setCursorPos(x,y) end
- function stc(clr) return term.setTextColor(clr) end
- function sbc(clr) return term.setBackgroundColor(clr) end
- function c() return term.clear() end
- function cl() return term.clearLine() end
- function w(text) return write(text) end
- function rednet.checkModem()
- for n,sModem in ipairs(peripheral.getNames()) do
- if peripheral.getType(sModem) == "modem" then
- return sModem
- end
- end
- return false
- end
- local oldTostring = tostring
- tostring = function(numberTable,more)
- if type(numberTable) == "table" then
- local extractedText = ""
- if not more then
- more = " "
- end
- for _,tableExtract in pairs(numberTable) do
- extractedText = extractedText..tableExtract..more
- end
- return extractedText
- else
- return oldTostring(numberTable)
- end
- end
- local function rednetAll(var)
- local output = 0
- for n,sModem in ipairs(peripheral.getNames()) do
- if peripheral.getType(sModem) == "modem" then
- if not rednet.isOpen(sModem) then
- output = output+1
- if var == "open" then
- rednet.open(sModem)
- elseif var == "close" then
- rednet.close(sModem)
- end
- end
- end
- end
- if output == 0 then
- return false
- end
- return output
- end
- function rednet.openAll() return rednetAll("open") end
- function rednet.closeAll() return rednetAll("close") end
- function colors.random()
- local colorTable4Bit = {1,2,4,8,16,32,64,128,256,512,1024,2048,4096,8192,16384,32768}
- local colorTable2Bit = {1,128,256,32768}
- if term.isColor() then
- return colorTable4Bit[math.random(1,16)]
- end
- return colorTable2Bit[math.random(1,4)]
- end
- function textutils.delayWrite(text,delay)
- if type(text) ~= "string" or type(delay) ~= "number" then
- error("string,number expected.")
- end
- for stringSub = 1, string.len(text) do
- write(string.sub(text,stringSub,stringSub))
- sleep(delay)
- end
- end
- function colors.getTable()
- if term.isColor() then
- return {1,2,4,8,16,32,64,128,256,512,1024,2048,4096,8192,16384,32768}
- end
- return {1,128,256,32768}
- end
- function textutils.delayPrint(text,delay)
- textutils.delayWrite(text,delay)
- print("")
- end
- function string.random(nStringLen)
- if type(nStringLen) ~= "number" then
- error("number expected.")
- end
- local aviableChars = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890@|\\/%&()=?}][{´`'#*~+,.-;:_<>^°\"$!"
- local output = ""
- for returnOutput = 1, nStringLen do
- subRandom = math.random(1,string.len(aviableChars))
- output = output..string.sub(aviableChars,subRandom,subRandom)
- end
- return output
- end
- function fs.write(path,text)
- if type(path) ~= "string" or type(text) ~= "string" then
- error("string,string expected.")
- end
- local file = assert(fs.open(path,"w"))
- file.write(text)
- file.close()
- end
- function fs.writeFromTable(path,t)
- if type(path) ~= "string" or type(t) ~= "table" then
- error("string,table expected.")
- end
- fs.write(path,tostring(t,"\n"))
- end
- function fs.getLine(path,ln)
- if type(path) ~= "string" or type(ln) ~= "number" then
- error("string,number expected.")
- end
- if not fs.exists(path) then
- error("file "..path.." doesn't exist.")
- end
- local file = fs.open(path,"r")
- return file.readLine(ln)
- end
- function fs.getTable(path)
- if type(path) ~= "string" then
- error("string expected.")
- end
- if not fs.exists(path) then
- error("file "..path.." doesn't exist.")
- end
- local file = fs.open(path,"r")
- local nLine = 1
- local lines = {}
- local line = file.readLine("*1")
- while line ~= nil do
- lines[nLine] = line
- nLine = nLine+1
- line = file.readLine("*1")
- end
- return lines
- end
- function fs.getString(path)
- if type(path) ~= "string" then
- error("string expected.")
- end
- if not fs.exists(path) then
- error("file "..path.." doesn't exist.")
- end
- local file = fs.open(path,"r")
- return file.readAll()
- end
- function fs.replaceLine(path,ln,text)
- if type(path) ~= "string" or type(ln) ~= "number" or type(text) ~= "string" then
- error("string,number,string expected.")
- end
- if not fs.exists(path) then
- error("file "..path.." doesn't exists")
- end
- local lines = fs.getTable(path)
- lines[ln] = text
- fs.writeFromTable(path,lines)
- end
- function fs.append(path,text)
- if type(path) ~= "string" or type(path) ~= "string" then
- error("string,string expected.")
- end
- if not fs.exists(path) then
- error("file "..path.." doesn't exist.")
- end
- local file = assert(fs.open(path,"a"))
- file.write(text)
- file.close()
- end
- local oldWrite = write
- write = function(s)
- local toggle = 0
- for i = 1, string.len(s) do
- if toggle == 0 then
- local ccv = string.sub(s,i,i+3)
- if string.sub(s,i,i) == "#" and string.sub(s,i+3,i+3) then
- toggle = 3
- else
- oldWrite(string.sub(s,i,i))
- end
- if ccv == "#wh#" then
- stc(1)
- elseif ccv == "#or#" then
- stc(2)
- elseif ccv == "#ma#" then
- stc(4)
- elseif ccv == "#lb#" then
- stc(8)
- elseif ccv == "#ye#" then
- stc(16)
- elseif ccv == "#li#" then
- stc(32)
- elseif ccv == "#pi#" then
- stc(64)
- elseif ccv == "#gy#" then
- stc(128)
- elseif ccv == "#lg#" then
- stc(256)
- elseif ccv == "#cy#" then
- stc(512)
- elseif ccv == "#pu#" then
- stc(1024)
- elseif ccv == "#bl#" then
- stc(2048)
- elseif ccv == "#br#" then
- stc(4096)
- elseif ccv == "#gr#" then
- stc(8192)
- elseif ccv == "#re#" then
- stc(16384)
- elseif ccv == "#bl#" then
- stc(32768)
- elseif ccv == "#ra#" then
- stc(colors.random())
- end
- else
- toggle = toggle-1
- end
- end
- end
- print = function(s)
- return write(s.."\n")
- end
- ZANQUAL API LOADER:
- local oldShutd = os.shutdown
- local oldReboot = os.reboot
- local function rgm()
- if fs.exists("startup") then
- fs.copy("startup","startupBackup")
- fs.delete("startup")
- end
- fs.copy("ZanqualScript/Zanqual_API_Loader_Startup","startup")
- end
- os.shutdown = function()
- rgm()
- oldShutd()
- end
- os.reboot = function()
- rgm()
- oldReboot()
- end
- ZANQUAL API LOADER STARTUP:
- fs.delete("startup")
- if fs.exists("startupBackup") then
- fs.move("startupBackup","startup")
- end
- shell.run("ZanqualScript/Zanqual_API_Loader")
- shell.run("ZanqualScript/Zanqual")
- ZANQUAL CHANGELOG:
- New stuff added (removed from) to Zanqual v0.4:
- + added shortcut-functions:
- none
- + added new functions:
- string.random(lenght) - Returns a random generated string with any english letters,numbers and symbols.
- + modified functions:
- write(string) - Now can change into any color without using term.setTextColor(...):
- #wh# = white, #or# = orange, #ma# = magenta, #lb# = light blue, #ye# = yellow, #li# = lime, #pi# = pink, #gy# = gray,
- #lg# = light gray, #cy# = cyan, #pu# = purple, #bl# = blue, #br# = brown, #gr# = green, #re# = red, #bl# = black, #ra# = random color
- print(string) - Does the same like write(...) but writes "\n" at the end.
- ~ changed stuff:
- fixed string.random(...):
- I, the spoon, forgot to place a type(...) at the non-number detector! :/
- - removed
- nothing
- --]]
Add Comment
Please, Sign In to add comment