Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --[[DONT REMOVE THIS NOTICE!!!
- Download: pastebin get Sg5rWMqD CGTmath || http://www.pastebin.com/Sg5rWMqD
- Copyright ©COOLGAMETUBE
- Copyright ©Buschrolle
- Copyright ©JcraftxD
- Release: 30.07.2015
- EULA:
- -I will not share this API whithout this notice!
- -I able to modify aCFFnd reupload it, if this notice was not removed.
- -I will credit COOLGAMETUBE.
- -I able to set my Credit, if this Programm has modified(New Functions)
- -This API will be FREE (no money)
- -If i upload a programm, that include this API, i will set the Credits of COOLGAMETUBE]]
- tArgs = {...}
- local function DrawUsage()
- print("Usage: CGTmath help")
- print("Usage: CGTmath Usage")
- print("Usage: CGTmath GetVersion")
- print("Usage: CGTmath GetAuthor")
- print("Usage: CGTmath MagicClear")
- print("Usage: CGTmath MagicSpam")
- print("Usage: CGTmath digit_sum <number>")
- print("Usage: CGTmath invert <number>")
- print("Usage: CGTmath toInt <string (&) number>")
- end
- function Updates(fromTerm)
- rtMSG = "No more Updates will come! All new Functions will be implemeted in the \"WicowsTools\" API! \n Update: http://pastebin.com/REaZXV7W"
- if fromTerm then
- print(rtMSG)
- else
- return rtMSG
- end
- end
- function GetAuthor()
- return "COOLGAMETUBE"
- end
- function GetVersion()
- return 1.1
- end
- function MagicClear()
- l = {"[", "-", "]", " ", 0.5}
- 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
- shell.run("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 = ""
- 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" then
- num = num .. l
- 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
- local Ac = #tArgs
- local mnum = 0
- if Ac > 0 then
- local func = tArgs[1]
- if Ac > 1 then mnum = tArgs[2] end
- if func == "help" then DrawUsage()
- elseif func == "Usage" then DrawUsage()
- elseif func == "GetVersion" then GetVersion()
- elseif func == "GetAuthor" then GetAuthor()
- elseif func == "MagicClear" then MagicClear()
- elseif func == "MagicSpam" then MagicSpam()
- elseif func == "digit_sum" then if Ac > 1 then print("Result: "..tostring(digit_sum(mnum))) else DrawUsage() end
- elseif func == "invert" then if Ac > 1 then print("Result: "..tostring(invert(mnum))) else DrawUsage() end
- elseif func == "toInt" then if Ac > 1 then print("Result: "..tostring(toInt(mnum))) else DrawUsage() end
- else
- DrawUsage()
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement