Lua plugins in Vocode cannot access the Lua standard library

For security, plugins can only access core libraries and those tied to granted permissions.

🌏 Global

tonumber(value)

Converts a string representation of a number to an integer.

Example

tonumber("123")

🧮 Math API

The math library includes various mathematical functions.

math.abs(x)

Returns the absolute value of x.

math.abs(-10)

math.acos(x)

Returns the arc cosine of x (in radians).

math.acos(0)

math.asin(x)

Returns the arc sine of x (in radians).

math.asin(1)

math.atan(x)

Returns the arc tangent of x (in radians).

math.atan(1)

math.atan2(y, x)

Returns the arc tangent of y/x (in radians).

math.atan2(1, 1)

math.ceil(x)

Rounds x up to the nearest integer.

math.ceil(1.2)

math.cos(x)

Returns the cosine of x (in radians).

math.cos(0)

math.exp(x)

Returns the exponential function e^x.

math.exp(1)

math.floor(x)

Rounds x down to the nearest integer.

math.floor(1.9)

math.log(x)

Returns the natural logarithm of x.

math.log(10)

math.max(x, ...)

Returns the maximum value among arguments.

math.max(1, 3, 7, 2)

math.min(x, ...)

Returns the minimum value among arguments.

math.min(1, 3, 7, 2)

math.pow(x, y)

Returns x raised to the power of y.

math.pow(2, 3)

math.random(m, n)

Returns a random integer between m and n.

math.random(1, 10)

math.pi

Returns the value of π.

math.pi

🔤 String API

The string library provides utility functions for string manipulation.

string.upper(str)

Converts a string to uppercase.

string.upper("hello")

string.lower(str)

Converts a string to lowercase.

string.lower("HELLO")

string.gsub(str, find, replace)

Replaces occurrences of find with replace in str.

string.gsub("hello world", "world", "Lua")

string.find(str, find)

Finds the first occurrence of find in str.

string.find("hello world", "world")

string.reverse(str)

Reverses the string.

string.reverse("hello")

string.format(format, ...)

Formats a string using sprintf-style formatting.

string.format("%d + %d = %d", 2, 3, 2+3)

string.char(code)

Returns the character corresponding to the ASCII code.

string.char(65)

string.byte(str, index)

Returns the ASCII code of the character at the given index.

string.byte("A")

string.len(str)

Returns the length of str.

string.len("hello")

string.rep(str, count)

Repeats str count times.

string.rep("Lua ", 3)