Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --[[DONT REMOVE THIS NOTICE!!!
- Download: pastebin get REaZXV7W WicowsTools || http://www.pastebin.com/REaZXV7W
- Copyright ©COOLGAMETUBE
- Copyright ©Buschrolle
- Copyright ©JcraftxD
- Release: 11.08.2015
- Updated: 10.04.2016
- EULA:
- -I will not share this API whithout this notice!
- -I'm able to modify and reupload it, if this notice haven't been removed.
- -I will credit COOLGAMETUBE.
- -I'm able to set my Credit, if this API has been modified(New Functions)
- -This API will be FREE available (no money)--]]
- function packmanSystem()
- if fs.exists("/usr/bin/packman") then
- return true
- else
- return false
- end
- end
- local tArgs = {...}
- function GetAuthor()
- return "COOLGAMETUBE"
- end
- function GetVersion()
- return 1.311
- end
- function MagicClear(t)
- if not t then t = 0.5 end
- l = {"[", "-", "]", " ", t}
- x, y = term.getSize()
- lt = ""
- ct = ""
- for i = 1, x do
- le = l[2]
- if i == 1 then le = l[1] end
- if i == x then le = l[3] end
- lt = lt .. le
- ct = ct .. l[4]
- end
- for i = 1, y do
- term.setCursorPos(1, i -1)
- write(ct)
- term.setCursorPos(1, i)
- write(lt)
- sleep(l[5])
- end
- term.setCursorPos(1, 1)
- term.clear()
- end
- function MagicSpam()
- s = 0.1
- x, y = term.getSize()
- lt = ""
- scnd = true
- for i = 1, y do
- for i = 1, x do
- lt = lt .. tostring(math.random(0,9))
- end
- term.setCursorPos(1, i)
- write(lt)
- if scnd then
- sleep(s)
- scnd = false
- else
- scnd = true
- end
- end
- term.setCursorPos(1,y)
- end
- function toInt(str)
- num = ""
- sp = false
- for a = 1, string.len(str) do
- l = string.sub(str, a,a)
- if l == "0"
- or l == "1"
- or l == "2"
- or l == "3"
- or l == "4"
- or l == "5"
- or l == "6"
- or l == "7"
- or l == "8"
- or l == "9"
- or l == "." then
- if l == "." and not sp then
- num = num .. l
- elseif l ~= "." then
- num = num .. l
- end
- end
- end
- if num == "" or num == nil then num = 0 end
- return tonumber(num)
- end
- function digit_sum(num)
- num = toInt(num)
- num = tostring(num)
- numlet = {}
- if string.len(num) > 1 then
- for a = 1, string.len(num) do
- numlet[a] = string.sub(num, a,a)
- end
- else
- numlet[1] = num
- end
- local result = nil
- if #numlet > 1 then
- local rn = 0
- for i = 1, #numlet do
- rn = rn + toInt(numlet[i])
- end
- result = rn
- else
- result = toInt(numlet[1])
- end
- return result
- end
- function invert(num)
- num = toInt(num)
- num = tostring(num)
- numlet = {}
- if string.len(num) > 1 then
- for a = 1, string.len(num) do
- numlet[a] = string.sub(num, a,a)
- end
- else
- numlet[1] = num
- end
- local result = nil
- if #numlet > 1 then
- local rn = ""
- for i = 1, (#numlet) do
- rn = rn..numlet[#numlet-i+1]
- end
- result = rn
- else
- result = numlet[1]
- end
- return result
- end
- function SplitStr(inputstr, sep)
- if sep == nil then
- sep = "%s"
- end
- local t={} ; i=1
- if string.gmatch(inputstr, "([^"..sep.."]+)") then
- for str in string.gmatch(inputstr, "([^"..sep.."]+)") do
- t[i] = str
- i = i + 1
- end
- end
- return t
- end
- function ReplaceStr(str, rep, to)
- if not rep then return nil end
- str = tostring(str)
- local pcs = SplitStr(str, rep)
- str = pcs[1]
- for n=2,#pcs do
- str = str..to..pcs[n]
- end
- return str
- end
- function WriteFile(file, text, append)
- local m = "w"
- if append == true then
- m = "a"
- end
- if not fs.exists(file) then
- if not fs.isReadOnly(file) then
- f = fs.open(file, m)
- f.write(text)
- f.close()
- return true
- else
- return false
- end
- else
- return false
- end
- end
- function ReadFile(file)
- if fs.exists(file) then
- local f = fs.open(file, "r")
- local text = f.readAll()
- f.close()
- if text ~= nil then
- return text
- else
- return "ERROR!"
- end
- else
- return false
- end
- end
- function safeSet(default, with)
- if with then
- ret = with
- else
- ret = default
- end
- return ret
- end
- function SimpleClear()
- term.setBackgroundColor(colors.black)
- term.setTextColor(colors.white)
- term.clear()
- term.setCursorPos(1, 1)
- end
- function CreateBorder(vwx, vwy, vx, vy)
- local letters = {"+","-","|",}
- local wx = safeSet(0, vwx)
- local wy = safeSet(0, vwy)
- local x,y = term.getSize()
- if vy and vx then
- x = vx
- y = vy
- else
- term.clear()
- end
- local cy = 1
- local lt = ""
- for i = 1, y do
- cy = i
- lt = ""
- for i = 1, x do
- if cy == 1 and i == 1 then
- lt = lt..letters[1]
- elseif cy == 1 and i == x then
- lt = lt..letters[1]
- elseif cy == y and i == 1 then
- lt = lt..letters[1]
- elseif cy == y and i == x then
- lt = lt..letters[1]
- elseif cy == 1 then
- lt = lt..letters[2]
- elseif cy == y then
- lt = lt..letters[2]
- elseif i == 1 then
- lt = lt..letters[3]
- elseif i == x then
- lt = lt..letters[3]
- else
- lt = lt.." "
- end
- end
- term.setCursorPos(wx+1, wy+i)
- write(lt)
- end
- end
- function is(var)
- if var then
- return true
- else
- return false
- end
- end
- function Log(msg, terminal, add)
- if terminal then
- if terminal == term or terminal == term.current() then
- if add then
- term.write(msg)
- else
- print(msg)
- end
- else
- if add then
- terminal.write(msg)
- else
- x, y = terminal.getCursorPos()
- terminal.write(msg)
- terminal.setCursorPos(1, y+1)
- end
- end
- end
- end
- function GetRawWebString(url)
- if type(url) ~="string" then
- error("Can't execute function GetRawWebString(string) because parameter[1] is not a string!")
- return false
- end
- local connection = http.get(url)
- if connection then
- local result = connection.readAll()
- connection.close()
- return result
- else
- return false
- end
- end
- function CheckCompatible(file, returnVersion, outputTerm)
- t = nil
- o = nil
- funcList = nil
- osv = nil
- fo = nil
- f = nil
- foundMv = nil
- -------------
- t = outputTerm
- o = is(returnVersion)
- funcList = textutils.unserialize(GetRawWebString("http://pastebin.com/raw.php?i=tvVjyfHD"))
- osv = toInt(_CC_VERSION)
- fo = fs.open(file, "r")
- f = fo.readAll()
- fo.close()
- foundMv = false
- for i = 1, #funcList["list"] do
- if not foundMv then
- Log("Check Version: "..funcList["list"][i]["vers"].." ...", t)
- sleep(0.01) --yielding!
- for fu = 1, #funcList["list"][i]["funcList"] do
- sleep(0.01) --yielding!
- if string.find(f, "turtle.")
- and trutle
- or not string.find(f, "turtle.")
- and not turtle then
- if string.find(f, funcList["list"][i]["funcList"][fu]) then
- foundMv = funcList["list"][i]["vers"]
- end
- end
- end
- end
- end
- r = nil
- if foundMv then
- if foundMv > osv then
- Log("false, NOT compatible! Min Version: "..foundMv, t)
- r = false
- else
- Log("true, Min Version: "..foundMv, t)
- r = true
- end
- else
- Log("true, Min Version: First Release!", t)
- r = true
- end
- if o then
- return r, foundMv
- else
- return r
- end
- end
- function GetWebHash(HashType, Data)
- return GetRawWebString("http://coolgametube.net/cc/hash.php?mode="..HashType.."&str="..Data)
- end
- function BigChar(char)
- if char == "a" then return "A"
- elseif char == "b" then return "B"
- elseif char == "c" then return "C"
- elseif char == "d" then return "D"
- elseif char == "e" then return "E"
- elseif char == "f" then return "F"
- elseif char == "g" then return "G"
- elseif char == "h" then return "H"
- elseif char == "i" then return "I"
- elseif char == "j" then return "J"
- elseif char == "k" then return "K"
- elseif char == "l" then return "L"
- elseif char == "m" then return "M"
- elseif char == "n" then return "N"
- elseif char == "o" then return "O"
- elseif char == "p" then return "P"
- elseif char == "q" then return "Q"
- elseif char == "r" then return "R"
- elseif char == "s" then return "S"
- elseif char == "t" then return "T"
- elseif char == "u" then return "U"
- elseif char == "v" then return "V"
- elseif char == "w" then return "W"
- elseif char == "x" then return "X"
- elseif char == "y" then return "Y"
- elseif char == "z" then return "Z"
- elseif char == "ä" then return "Ä"
- elseif char == "ö" then return "Ö"
- elseif char == "ü" then return "Ü"
- else return char end
- end
- function BigLetters(text)
- local BStr = ""
- for i = 1, string.len(text) + 1 do
- BStr = BStr..BigChar(string.sub(text, i,i))
- end
- return BStr
- end
- function boolStr(obj)
- res = is(obj)
- if res then
- return "true"
- else
- return "false"
- end
- end
- function getCenterStart(objSize, screenSize)
- return ((screenSize/2)-(objSize/2))
- end
- function compareTables(t1,t2,ignore_mt)
- local ty1 = type(t1)
- local ty2 = type(t2)
- if ty1 ~= ty2 then return false end
- if ty1 ~= 'table' and ty2 ~= 'table' then return t1 == t2 end
- local mt = getmetatable(t1)
- if not ignore_mt and mt and mt.__eq then return t1 == t2 end
- for k1,v1 in pairs(t1) do
- local v2 = t2[k1]
- if v2 == nil or not compareTables(v1,v2) then return false end
- end
- for k2,v2 in pairs(t2) do
- local v1 = t1[k2]
- if v1 == nil or not compareTables(v1,v2) then return false end
- end
- return true
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement