Welcome to the KittyLib documentation.
Made for version 0.1.1
- string
- table
- math
- common
An expanded version of the default string library.
LuaU
Lua5.1
Lua5.4
string.split(s: string, sep: string): ({string}, number)
Splits the string into parts based on the seperator string, also returns the amount of times the string has been split.
local str = "Hello World!"
local splitstr, splitamount = string.split(str, " ")
print(splitstr[1], splitstr[2], splitamount) --> [1]"Hello" [2]"World!" [3]1
LuaU
Lua5.1
string.divide(s: string, div: number): {string}
Similair to string.split
but instead of splitting the string based on another string, it splits the string based on how many times it needs to be split.
local str = "Hello World!"
local div = 4
local dividedstring = string.divide(str, div)
print(dividedstring[1], dividedstring[2], dividedstring[3], dividedstring[4]) --> [1]"Hel" [2]"lo " [3]"Wor" [4]"ld!"
Expansion to the default table library.
LuaU
Lua5.1
Lua5.4
table.tostring(t: {}, mode: number? <0, 1>): string
Converts a table to almost an exact string replica of the original, it cannot turn functions or nil values into strings though.
local tabletoConvert = {
1,
one = 1,
"string",
["twenty two"] = 22,
true,
nil,
[{"table index"}] = {
"string"
}
}
print(table.tostring(tabletoConvert, 0)) --> {[1] = 1, [2] = "string", [3] = true, one = 1, [{[1] = "table index"}] = {[1] = "string"}, ["twenty two"] = 22}
print(table.tostring(tabletoConvert, 1))
--[[-->
{
[1] = 1,
[2] = "string",
[3] = true,
one = 1,
[{[1] = "table index"}] = {
[1] = "string"
},
["twenty two"] = 22
}
]]
LuaU
Lua5.1
Lua5.4
table.copy(t: {}): {}
Deepclones a table, same as most deepclone functions you can find on google.
LuaU
table.deepfreeze(t: {})
Freezes a table and its descendants which are also a table.
LuaU
table.isdeepfrozen(t: {}): boolean
Checks a table and its descendants if they are frozen, if one is not frozen, it will return false
LuaU
Lua5.1
Lua5.4
table.destroy(t: {}): {}
Clears a table and its descendant tables.
LuaU
Lua5.1
Lua5.4
table.replace(t: {}, vt: {}): {}
Replaces each value in t
which has the same index as in vt
LuaU
Lua5.1
Lua5.4
table.deepreplace(t: {}, vt: {}): {}
Same as table.replace
but instead replaces values in table values as well.
LuaU
Lua5.1
Lua5.4
table.find(t: {}, value: any): number?
Documentation for table.find except it has no init argument.
LuaU
Lua5.1
Lua5.4
table.findkey(t: {}, index: string): number?
Finds the number index of index
, returns nil if it cannot be found.
LuaU
Lua5.1
Lua5.4
table.len(t: {}): number
Returns the full length of a table, including string indexed values.
LuaU
Lua5.1
Lua5.4
table.deeplen(t: {}): number
Returns the length of the whole table including descendant table lengths.
(Already in LuaU)
Lua5.1
Lua5.4
table.clear(t: {}): {}
Clears the entire table.
Some features from Lua5.4
ported over to LuaU
and Lua5.1
, and some other functions.
LuaU
Lua5.1
(Already in 5.4)
math.type(n: number): ("integer" | "float")?
Returns "integer"
if n
is an integer, "float"
if it is a float, or nil if n
is not a number.
LuaU
Lua5.1
(Already in 5.4)
math.tointeger(float: number): number?
If the float is convertible to an integer, it will return an integer of that float, returns nil otherwise.
LuaU
Lua5.1
(Already in 5.4)
math.ult(m: number, n: number): boolean
Returns a boolean, true if and only if integer m
is below integer n
when they are compared as unsigned integers.
LuaU
Lua5.1
Lua5.4
math.rounddec(n: number, decimal: number): number
Returns a float with a rounded decimal count
LuaU
Lua5.1
Lua5.4
math.decimal(n: number): number?
Counts and returns the amount of decimals behind a float, returns nil if it is not a float.
LuaU
Lua5.4
math.tobinary(n: number): string
Returns a binary string of a number, the input number cannot be a float.
LuaU
Lua5.4
math.frombinary(binary: string): number
Converts a binary string into a number.
LuaU
Lua5.1
Lua5.4
math.randomfloat(min: number, max: number, decimal: number?)
Generates a more accurate random float, with an optional decimal count to control how many random decimals come after.