Useful Utilities for Lua!
This file was made firstly for myself, but then I wanted to share it with people, so here it is!
string.random(count,min,max)"count, min, max" are not required, this function returns a random stringstring.split(str,split)this function splits a string to a tablestring.mix(str)seemixstring.startswith(str,pattern)verify if a string starts with the patternstring.endswith(str,pattern)same as above but for the end of the stringstring.encodetable for encodingstring.decodetable for decodingstring.encode.hex(str)encode a string into hexstring.decode.hex(str)decode a string into hexstring.encode.b64(str)encode a string into base64string.decode.b64(str)decode a string into base64string.totabletransforms a string to a table
io.readfile(path/to/file.txt)reads a fileio.store(file,content,true)stores data into a file, the "true" mean we do a new line at the end of the file for future storing
math.mixseemixmath.calcCalculator sandboxed (You can't inject code)
os.find("file","dir")search for a file in a directoryos.clear()clear the terminal, works with all OSos.getOS()returns the current OSos.getArch()get if the arch is 64 bits or 32 bitsos.outputexec
Get the output of a system commandos.splitpath(path)Splits the path
table.merge(t1,t2)merges two tablestable.to2D(str)returns a 2D table version of the string you senttable.tostring(tbl)returns a string of the table you senttable.list(tbl)return in a string a list of elements of a table, also returns counttable.head(tbl)returns first valuetable.tail(tbl)returns the tail of the tabletable.find(tbl)find a value in a tabletable.reverse(tbl)reverses a table. Warning: only works with normal keys (1,2,3..)
console.log(str)logs something with time and dateconsole.slowPrint(str)prints something slowlyconsole.slowWrite(str)writes something slowly (using io.write)console.error(error type, error message, additional infos)advanced erroringconsole.update(bool,str...)Will update the console, bool: is the text slowly appearing.
sleep(t)will wait the amount of time givenoperatorOperators, can always be usefulmorseA table with char for morse in itcharsa string with all chars, used forstring.encode.b64(str)mixmix a string or intsdostringa remake of the old loadstring for Lua 5.3 - execute a string as a piece of codeisTypeShorter for type(obj) == "obj"