std

package
v0.0.0-...-6afea1d Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 22, 2025 License: Unlicense Imports: 16 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Globals = []Function{
	MakeFn("type", global_type),

	MakeFn("ipairs", global_ipairs),
	MakeFn("pairs", global_pairs),
	MakeFn("next", global_next),
	MakeFn("tonumber", global_tonumber),
	MakeFn("tostring", global_tostring),
	MakeFn("require", global_require),
}
View Source
var Libargs = NewLib([]Function{
	MakeFn("web", args_web),
})
View Source
var Libbit32 = NewLib([]Function{
	MakeFn("arshift", bit32_arshift),
	MakeFn("band", bit32_band),
	MakeFn("bnot", bit32_bnot),
	MakeFn("bor", bit32_bor),
	MakeFn("btest", bit32_btest),
	MakeFn("bxor", bit32_bxor),
	MakeFn("byteswap", bit32_byteswap),
	MakeFn("countlz", bit32_countlz),
	MakeFn("countrz", bit32_countrz),
	MakeFn("extract", bit32_extract),
	MakeFn("lrotate", bit32_lrotate),
	MakeFn("lshift", bit32_lshift),
	MakeFn("replace", bit32_replace),
	MakeFn("rrotate", bit32_rrotate),
	MakeFn("rshift", bit32_rshift),
})
View Source
var Libbuffer = NewLib([]Function{
	MakeFn("create", buffer_create),
	MakeFn("fromstring", buffer_fromstring),
	MakeFn("tostring", buffer_tostring),
	MakeFn("len", buffer_len),
	MakeFn("readi8", buffer_readi8),
	MakeFn("readu8", buffer_readu8),
	MakeFn("readi16", buffer_readi16),
	MakeFn("readu16", buffer_readu16),
	MakeFn("readi32", buffer_readi32),
	MakeFn("readu32", buffer_readu32),
	MakeFn("readf32", buffer_readf32),
	MakeFn("readf64", buffer_readf64),
	MakeFn("writei8", buffer_writei8),
	MakeFn("writeu8", buffer_writeu8),
	MakeFn("writei16", buffer_writei16),
	MakeFn("writeu16", buffer_writeu16),
	MakeFn("writei32", buffer_writei32),
	MakeFn("writeu32", buffer_writeu32),
	MakeFn("writef32", buffer_writef32),
	MakeFn("writef64", buffer_writef64),
	MakeFn("readbits", buffer_readbits),
	MakeFn("writebits", buffer_writebits),
	MakeFn("readstring", buffer_readstring),
	MakeFn("writestring", buffer_writestring),
	MakeFn("copy", buffer_copy),
	MakeFn("fill", buffer_fill),
})
View Source
var Libcoroutine = NewLib([]Function{
	MakeFn("close", coroutine_close),
	MakeFn("create", coroutine_create),
	MakeFn("isyieldable", coroutine_isyieldable),
	MakeFn("resume", coroutine_resume),
	MakeFn("running", coroutine_running),
	MakeFn("status", coroutine_status),
	MakeFn("wrap", coroutine_wrap),
	MakeFn("yield", coroutine_yield),
})
View Source
var Libmath = NewLib([]Function{
	MakeFn("abs", math_abs),
	MakeFn("acos", math_acos),
	MakeFn("asin", math_asin),
	MakeFn("atan", math_atan),
	MakeFn("atan2", math_atan2),
	MakeFn("ceil", math_ceil),
	MakeFn("clamp", math_clamp),
	MakeFn("cos", math_cos),
	MakeFn("cosh", math_cosh),
	MakeFn("deg", math_deg),
	MakeFn("exp", math_exp),
	MakeFn("floor", math_floor),
	MakeFn("fmod", math_fmod),
	MakeFn("frexp", math_frexp),
	MakeFn("ldexp", math_ldexp),
	MakeFn("lerp", math_lerp),
	MakeFn("log", math_log),

	MakeFn("map", math_map),
	MakeFn("max", math_max),
	MakeFn("min", math_min),
	MakeFn("modf", math_modf),
	MakeFn("noise", math_noise),
	MakeFn("pow", math_pow),
	MakeFn("rad", math_rad),

	MakeFn("round", math_round),
	MakeFn("sign", math_sign),
	MakeFn("sin", math_sin),
	MakeFn("sinh", math_sinh),
	MakeFn("sqrt", math_sqrt),
	MakeFn("tan", math_tan),
	MakeFn("tanh", math_tanh),
}, map[string]Val{
	"huge": math.Inf(1),
	"pi":   math.Pi,
})
View Source
var Libstring = NewLib([]Function{
	MakeFn("byte", string_byte),
	MakeFn("char", string_char),
	MakeFn("find", string_find),
	MakeFn("format", string_format),
	MakeFn("gmatch", string_gmatch),
	MakeFn("gsub", string_gsub),
	MakeFn("len", string_len),
	MakeFn("lower", string_lower),
	MakeFn("match", string_match),

	MakeFn("rep", string_rep),
	MakeFn("reverse", string_reverse),
	MakeFn("split", string_split),
	MakeFn("sub", string_sub),

	MakeFn("upper", string_upper),
})
View Source
var Libtable = NewLib([]Function{
	MakeFn("clear", table_clear),
	MakeFn("clone", table_clone),
	MakeFn("concat", table_concat),
	MakeFn("create", table_create),
	MakeFn("find", table_find),
	MakeFn("freeze", table_freeze),
	MakeFn("insert", table_insert),
	MakeFn("isfrozen", table_isfrozen),
	MakeFn("maxn", table_maxn),
	MakeFn("move", table_move),
	MakeFn("pack", table_pack),
	MakeFn("remove", table_remove),
	MakeFn("sort", table_sort),
	MakeFn("unpack", table_unpack),
})
View Source
var Libutf8 = NewLib([]Function{
	MakeFn("char", utf8_char),
	MakeFn("codes", utf8_codes),
	MakeFn("codepoint", utf8_codepoint),
	MakeFn("len", utf8_len),
	MakeFn("offset", utf8_offset),

	MakeFn("nfcnormalize", utf8_nfcnormalize),
	MakeFn("nfdnormalize", utf8_nfdnormalize),
}, map[string]Val{
	"charpattern": "[\x00-\x7F\xC2-\xF4][\x80-\xBF]*",
})
View Source
var Libvector = NewLib([]Function{
	MakeFn("create", vector_create),
	MakeFn("magnitude", vector_magnitude),
	MakeFn("normalize", vector_normalize),
	MakeFn("cross", vector_cross),
	MakeFn("dot", vector_dot),
	MakeFn("angle", vector_angle),
	MakeFn("floor", vector_floor),
	MakeFn("ceil", vector_ceil),
	MakeFn("abs", vector_abs),
	MakeFn("sign", vector_sign),
	MakeFn("clamp", vector_clamp),
	MakeFn("max", vector_max),
	MakeFn("min", vector_min),
}, map[string]Val{
	"one":  Vector{1, 1, 1, 0},
	"zero": Vector{0, 0, 0, 0},
})

Functions

func Add

func Add(a, b Val) (Val, error)

func Div

func Div(a, b Val) (Val, error)

func Fmtstring

func Fmtstring(strfrmt string, args Args) (string, error)

func Ge

func Ge(a, b Val) (bool, error)

func Gt

func Gt(a, b Val) (bool, error)

func Idiv

func Idiv(a, b Val) (Val, error)

func Le

func Le(a, b Val) (bool, error)

vectors dont have these comparisons

func Lt

func Lt(a, b Val) (bool, error)

func MakeFn

func MakeFn(name string, f func(Args) ([]Val, error)) Function

MakeFn creates a new function with a given name and body. Functions created by MakeFn can be added to a library using NewLib.

func Mod

func Mod(a, b Val) (Val, error)

func Mul

func Mul(a, b Val) (Val, error)

func NewLib

func NewLib(functions []Function, other ...map[string]Val) *Table

NewLib creates a new library with a given table of functions and other values, such as constants. Functions can be created using MakeFn.

func Pow

func Pow(a, b Val) (Val, error)

func Sub

func Sub(a, b Val) (Val, error)

func ToString

func ToString(a Val) string

ToString returns a string representation of any value.

func TypeOf

func TypeOf(v Val) string

TypeOf returns the underlying VM datatype of a value as a string. This does not return the Luau type, as type() does.

func Unm

func Unm(a Val) (Val, error)

Types

type Args

type Args struct {
	// Co is the coroutine that the function is running.
	Co *Coroutine
	// List is the list of all arguments passed to the function.
	List []Val
	Name string
	// contains filtered or unexported fields
}

Args represents the arguments passed to a user-defined native function.

A number of helper functions are provided to extract arguments from the list. If these functions fail to extract the argument, the coroutine yields an invalid/missing argument error.

func (*Args) CheckNextArg

func (a *Args) CheckNextArg()

CheckNextArg ensures that there is at least one more argument to be read. If there isn't, the coroutine yields a missing argument error.

func (*Args) GetAny

func (a *Args) GetAny(optV ...Val) (arg Val)

GetAny returns the next argument.

func (*Args) GetBool

func (a *Args) GetBool(optV ...bool) bool

GetBool returns the next argument as a boolean value. An optional value can be passed if the argument is not required.

func (*Args) GetBuffer

func (a *Args) GetBuffer(optV ...*Buffer) *Buffer

GetBuffer returns the next argument as a buffer value. An optional value can be passed if the argument is not required.

func (*Args) GetCoroutine

func (a *Args) GetCoroutine(optV ...*Coroutine) *Coroutine

GetCoroutine returns the next argument as a coroutine value. An optional value can be passed if the argument is not required.

func (*Args) GetFunction

func (a *Args) GetFunction(optV ...Function) Function

GetFunction returns the next argument as a function value. An optional value can be passed if the argument is not required.

func (*Args) GetNumber

func (a *Args) GetNumber(optV ...float64) float64

GetNumber returns the next argument as a float64 number value. An optional value can be passed if the argument is not required.

func (*Args) GetString

func (a *Args) GetString(optV ...string) string

GetString returns the next argument as a string value. An optional value can be passed if the argument is not required.

func (*Args) GetTable

func (a *Args) GetTable(optV ...*Table) *Table

GetTable returns the next argument as a table value. An optional value can be passed if the argument is not required.

func (*Args) GetVector

func (a *Args) GetVector(optV ...Vector) Vector

GetVector returns the next argument as a vector value. An optional value can be passed if the argument is not required.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL