rbxmk

package module
v0.7.2 Latest Latest
Warning

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

Go to latest
Published: May 23, 2021 License: MIT Imports: 20 Imported by: 0

README

rbxmk logo

rbxmk is a command-line tool for manipulating Roblox files.

rbxmk is useful for development workflows that involve the combination of many separate files. If your project is organized as Lua files for scripting and model files for assets, rbxmk makes it simple to combine them into a final product, be it a game, plugin, model, module, and so on. rbxmk is also suitable for more simple actions, such as downloading models or publishing games.

Download

The current version of rbxmk is v0.7.2. The following builds are available for download:

Windows Mac Linux
Windows 64-bit macOS Linux 64-bit
Windows 32-bit Linux 32-bit

See the Release page for more information on the current version.

rbxmk is fully featured, but thorough testing of all features is still a work in progress. Please practice redundancy and use backups to reduce the risk of data loss. Be sure to report issues as you encounter them!

Usage

rbxmk primarily uses Lua scripts to produce and retrieve data, transform it, and send it off to a variety of sources. The main subcommand is run, which executes a script:

echo 'print("Hello world!")' > hello-world.lua
rbxmk run hello-world.lua
# Hello world!

The Documentation page provides a complete reference on how rbxmk is used, as well as the API of the Lua environment provided by rbxmk.

Examples

The examples directory contains examples of rbxmk scripts.

Installation

rbxmk can also be installed manually.

  1. Install Go
  2. Install Git
  3. Using a shell with Git (such as Git Bash), run the following command:
go install github.com/anaminus/rbxmk/rbxmk@latest

If you installed Go correctly, this will install the latest version of rbxmk to $GOPATH/bin, which will allow you run it directly from a shell.

A specific version of rbxmk may be installed by replacing latest with a version number (e.g. v0.7.2).

Development

To compile and install the bleeding-edge version, the best way is to clone the repository:

git clone https://github.com/anaminus/rbxmk
cd rbxmk/rbxmk
go install

Extra version information can be included by passing the -X flag to the linker:

go install -ldflags="-X $VARIABLE=$VALUE"
  • The main.Prerelease variable appends a prerelease version.
  • The main.Build variable appends build metadata.

For example:

go install -ldflags="-X main.Prerelease=rc.1 -X main.Build=$(echo $(git log -1 --format=%cI | date --utc +%Y%m%d)-$(git rev-parse --short HEAD))"
rbxmk version
# e.g. 0.5.1-rc.1+20210312-2070bf8

License

The source code for rbxmk is available under the MIT license.

Documentation

Index

Constants

View Source
const UserAgent = "RobloxStudio/WinInet rbxmk/0.0"

UserAgent is the User-Agent header string sent with HTTP requests made by rbxmk. It includes components that ensure the client will operate with Roblox website APIs.

Variables

This section is empty.

Functions

func CookiesFrom added in v0.6.0

func CookiesFrom(location string) (cookies rtypes.Cookies, err error)

CookiesFrom retrieves cookies from a known location. location is case-insensitive. The following locations are implemented:

  • studio: Returns the cookies used for authentication when logging into Roblox Studio.

func DecodeCookies added in v0.6.0

func DecodeCookies(r io.Reader) (cookies rtypes.Cookies, err error)

DecodeCookies parses cookies from r and returns a list of cookies. Cookies are parsed as a number of "Set-Cookie" HTTP headers. Returns an empty list if the reader is empty.

func DoHTTPRequest added in v0.6.0

func DoHTTPRequest(w *World, options rtypes.HTTPOptions) (resp *rtypes.HTTPResponse, err error)

DoHTTPRequest begins and resolves an HTTPRequest. Returns an error if the reponse did not return a successful status.

func EncodeCookies added in v0.6.0

func EncodeCookies(w io.Writer, cookies rtypes.Cookies) (err error)

EncodeCookies formats a list of cookies as a number of "Set-Cookie" HTTP headers and writes them to w.

func PullTypeFrom added in v0.3.0

func PullTypeFrom(t string) func(s State, lvs ...lua.LValue) (v types.Value, err error)

PullTypeFrom returns a Reflector.PullFrom that converts v from a userdata set with a type metatable registered as type t.

func PushPtrTypeTo added in v0.6.0

func PushPtrTypeTo(t string) func(s State, v types.Value) (lvs []lua.LValue, err error)

PushPtrTypeTo returns a Reflector.PushTo that converts v to a userdata set with a type metatable registered as type t. The same value will push the same userdata, making the value usable as a table key.

func PushTypeTo added in v0.3.0

func PushTypeTo(t string) func(s State, v types.Value) (lvs []lua.LValue, err error)

PushTypeTo returns a Reflector.PushTo that converts v to a userdata set with a type metatable registered as type t. Each push always produces a new userdata. This results in better performance, but makes the value unsuitable as a table key.

Types

type Client added in v0.4.0

type Client struct {
	*http.Client
	// contains filtered or unexported fields
}

Client wraps an http.Client to handle various additional behavior.

func NewClient added in v0.4.0

func NewClient(client *http.Client) *Client

NewClient returns an initialized Client. If *client* is nil, then http.DefaultClient is used.

func (*Client) Do added in v0.4.0

func (c *Client) Do(req *http.Request) (resp *http.Response, err error)

Do sends a request, with the following additional behaviors:

  • Includes a configured user agent header with the request, if the header is unset.
  • Handles CSRF token validation.

type Constructor added in v0.3.0

type Constructor struct {
	Func func(s State) int
	// Dump returns a description of constructor's API. Each function describes
	// one possible signature of the constructor.
	Dump func() dump.MultiFunction
}

Constructor creates a new value of a Reflector. The function can receive arguments from s.L, and must push a new value to s.L.

type Constructors added in v0.3.0

type Constructors map[string]Constructor

Constructors is a set of constructor functions keyed by name.

type FileEntry added in v0.6.0

type FileEntry struct {
	Path string
	os.FileInfo
}

FileEntry describes a file, including the full path. An empty Path indicates stdin.

type Format

type Format struct {
	// Name is the name that identifies the format. The name matches a file
	// extension.
	Name string

	// MediaTypes is a list of media types that are associated with the format,
	// to be used by sources as needed.
	MediaTypes []string

	// Options maps a field name to a value type. A FormatOptions received by
	// Encode or Decode will have only these fields. The value of a field, if it
	// exists, will be of the specified type.
	Options map[string]string

	// CanDecode returns whether the format decodes into the given type.
	CanDecode func(g Global, opt FormatOptions, typeName string) bool

	// Encode receives a value of one of a number of types and encodes it as a
	// sequence of bytes written to w.
	Encode func(g Global, opt FormatOptions, w io.Writer, v types.Value) error

	// Decode receives a sequence of bytes read from r, and decodes it into a
	// value of a single type.
	Decode func(g Global, opt FormatOptions, r io.Reader) (types.Value, error)
}

Format defines a format for encoding between a sequence of bytes and a types.Value. The format can be registered with a World.

type FormatOptions added in v0.3.0

type FormatOptions interface {
	// ValueOf returns the value of field. Returns nil if the value does not
	// exist.
	ValueOf(field string) types.Value
}

FormatOptions contains options to be passed to a Format.

type FrameType added in v0.6.0

type FrameType uint8

FrameType indicates the kind of frame for a State.

const (
	// Frame is a regular function.
	FunctionFrame FrameType = iota
	// Frame is a method; exclude first argument.
	MethodFrame
	// Frame is an operator, avoid displaying arguments.
	OperatorFrame
)

type Global added in v0.6.0

type Global struct {
	Desc       *rtypes.RootDesc
	AttrConfig *rtypes.AttrConfig
}

Global contains values that available across an entire World.

type HTTPRequest added in v0.6.0

type HTTPRequest struct {
	// contains filtered or unexported fields
}

HTTPRequest performs and HTTP request with a promise-like API.

func BeginHTTPRequest added in v0.6.0

func BeginHTTPRequest(w *World, options rtypes.HTTPOptions) (request *HTTPRequest, err error)

BeginHTTPRequest begins an HTTP request according to the given options, in the context of the given world.

The request starts immediately, and can either be resolved or canceled.

func (*HTTPRequest) Cancel added in v0.6.0

func (r *HTTPRequest) Cancel()

Cancel cancels the request.

func (*HTTPRequest) Resolve added in v0.6.0

func (r *HTTPRequest) Resolve() (*rtypes.HTTPResponse, error)

Resolve blocks until the request resolves.

func (*HTTPRequest) Type added in v0.6.0

func (*HTTPRequest) Type() string

Type returns a string identifying the type of the value.

type Library added in v0.3.0

type Library struct {
	// Name is a name that identifies the library.
	Name string
	// ImportedAs is the name that the library is imported as. Empty indicates
	// that the contents of the library are merged into the global environment.
	ImportedAs string
	// Open returns a table with the contents of the library.
	Open func(s State) *lua.LTable
	// Dump returns a description of the library's API.
	Dump func(s State) dump.Library
	// Types returns a list of type reflector expected by the library. Before
	// opening the library, each reflector is registered.
	Types []func() Reflector
}

Library represents a Lua library.

type Metamethod added in v0.3.0

type Metamethod func(s State) int

Metamethod is called when a metamethod is invoked.

type Metatable added in v0.3.0

type Metatable map[string]Metamethod

Metatable defines the metamethods of a custom type.

type Method added in v0.6.0

type Method struct {
	// Func is the body of the method. The first argument will be the same value
	// as v.
	Func func(s State, v types.Value) int
	// Dump returns a description of the member's API.
	Dump func() dump.Function
}

Method defines a member of a custom type.

type Methods added in v0.7.0

type Methods map[string]Method

Methods is a set of methods keyed by name.

type Properties added in v0.7.0

type Properties map[string]Property

Properties is a set of properties keyed by name.

type Property added in v0.7.0

type Property struct {
	// Get gets the value of a member from v and pushes it onto s. The index is
	// the 2nd argument in s.
	Get func(s State, v types.Value) int
	// Set gets a value from s and sets it to a member of v. The index and value
	// are the 2nd and 3rd arguments in s. Set is optional, if nil, the property
	// will be treated as read-only.
	Set func(s State, v types.Value)
	// Dump returns a description of the member's API.
	Dump func() dump.Property
}

Property defines a property of a custom type.

type Reflector added in v0.3.0

type Reflector struct {
	// Name is the name of the type.
	Name string

	Flags ReflectorFlags

	// Count indicates the number of Lua values that the type can reflect to and
	// from. A Count of 0 is the same as 1. Less than 0 indicates a variable
	// amount.
	Count int

	// PushTo converts v to a number of Lua values. l must be used only for the
	// conversion of values as needed. If err is nil, then lvs must have a
	// length of 1 or greater.
	PushTo func(s State, v types.Value) (lvs []lua.LValue, err error)

	// PullFrom converts a Lua value to v. l must be used only for the
	// conversion of values as needed. lvs must have a length of 1 or greater.
	PullFrom func(s State, lvs ...lua.LValue) (v types.Value, err error)

	// Metatable defines the metamethods of a custom type. If Metatable is
	// non-nil, then a metatable is constructed and registered as a type
	// metatable under Name.
	Metatable Metatable

	// Properties defines the properties of a custom type. If the __index and
	// __newindex metamethods are not defined by Metatable, then Properties
	// defines them according to the given properties. In case of name
	// conflicts, methods are prioritized over properties.
	Properties Properties

	// Symbols defines the symbols of a custom type. If the __index and
	// __newindex metamethods are not defined by Metatable, then Symbols defines
	// them according to the given properties.
	Symbols Symbols

	// Methods defines the methods of a custom type. If the __index and
	// __newindex metamethods are not defined by Metatable, then Methods defines
	// them according to the given members. In case of name conflicts, methods
	// are prioritized over properties.
	Methods Methods

	// Constructors defines functions that construct the type. If non-nil, a
	// table containing each constructor is created and set as a global
	// referenced by Name.
	Constructors Constructors

	// Environment is called after the type is registered to provide additional
	// setup.
	Environment func(s State)

	// ConvertFrom receives an arbitrary value and attempts to convert it to the
	// reflector's type. Returns nil if the value could not be converted.
	ConvertFrom func(v types.Value) types.Value

	// Types is a list of additional type reflectors that this reflector depends
	// on.
	Types []func() Reflector

	// Dump returns an additional description of the API of the reflector's
	// type. Member and constructor APIs should be described by their respective
	// fields.
	Dump func() dump.TypeDef
}

Reflector defines reflection behavior for a type. It defines how to convert a types.Value between a Lua value, and behaviors when the type is a userdata. It also defines functions for constructing values of the type. A Reflector can be registered with a World.

func (Reflector) DumpAll added in v0.6.0

func (r Reflector) DumpAll() dump.TypeDef

DumpAll returns a full description of the API of the reflector's type by merging the result of Dump, Members, and Constructors.

func (Reflector) ValueCount added in v0.3.0

func (r Reflector) ValueCount() int

ValueCount returns the normalized number of Lua values that the type reflects between. Less than 0 means the amount is variable.

type ReflectorFlags added in v0.3.0

type ReflectorFlags uint8
const (
	Exprim ReflectorFlags // Whether the type is an explicit primitive.
)

type State added in v0.3.0

type State struct {
	*World

	L *lua.LState

	// FrameType provides a hint to how errors should be produced.
	FrameType FrameType
	// contains filtered or unexported fields
}

State contains references to an environment surrounding a value.

func (State) ArgError added in v0.6.0

func (s State) ArgError(n int, msg string, v ...interface{}) int

ArgError raises an argument error depending on the state's frame type.

func (State) CheckAny added in v0.6.0

func (s State) CheckAny(n int) lua.LValue

CheckAny returns the nth argument, which can be any type as long as the argument exists.

func (State) CheckBool added in v0.6.0

func (s State) CheckBool(n int) bool

CheckBool returns the nth argument, expecting a boolean.

func (State) CheckFunction added in v0.6.0

func (s State) CheckFunction(n int) *lua.LFunction

CheckFunction returns the nth argument, expecting a function.

func (State) CheckInt added in v0.6.0

func (s State) CheckInt(n int) int

CheckInt returns the nth argument as an int, expecting a number.

func (State) CheckInt64 added in v0.6.0

func (s State) CheckInt64(n int) int64

CheckInt64 returns the nth argument as an int64, expecting a number.

func (State) CheckNumber added in v0.6.0

func (s State) CheckNumber(n int) lua.LNumber

CheckNumber returns the nth argument, expecting a number.

func (State) CheckString added in v0.3.0

func (s State) CheckString(n int) string

CheckString returns the nth argument, expecting a string. Unlike LState.CheckString, it does not try to convert non-string values into a string.

func (State) CheckTable added in v0.6.0

func (s State) CheckTable(n int) *lua.LTable

CheckTable returns the nth argument, expecting a table.

func (State) CheckThread added in v0.6.0

func (s State) CheckThread(n int) *lua.LState

CheckThread returns the nth argument, expecting a thread.

func (State) CheckUserData added in v0.6.0

func (s State) CheckUserData(n int) *lua.LUserData

CheckUserData returns the nth argument, expecting a userdata.

func (State) Count added in v0.3.0

func (s State) Count() int

Count returns the number of arguments in the stack frame.

func (*State) CycleClear added in v0.5.0

func (s *State) CycleClear()

CycleClear clears the cycle guard on the state. Panics if the state has no guard.

func (*State) CycleGuard added in v0.5.0

func (s *State) CycleGuard() bool

CycleGuard begins a guard against reference cycles when reflecting with the state. Returns false if a guard was already set up for the state. If true is returned, the guard must be cleared via CycleClear. For example:

if s.CycleGuard() {
    defer s.CycleClear()
}

func (State) CycleMark added in v0.5.0

func (s State) CycleMark(t interface{}) bool

CycleMark marks t as visited, and returns whether t was already visited. Panics if the state has no guard.

func (State) OptBool added in v0.6.0

func (s State) OptBool(n int, d bool) bool

OptBool returns the nth argument as a bool, or d if the argument is nil.

func (State) OptFunction added in v0.6.0

func (s State) OptFunction(n int, d *lua.LFunction) *lua.LFunction

OptFunction returns the nth argument as a function, or d if the argument is nil.

func (State) OptInt added in v0.6.0

func (s State) OptInt(n int, d int) int

OptInt returns the nth argument as an int, or d if the argument is nil.

func (State) OptInt64 added in v0.6.0

func (s State) OptInt64(n int, d int64) int64

OptInt64 returns the nth argument as an int64, or d if the argument is nil.

func (State) OptNumber added in v0.6.0

func (s State) OptNumber(n int, d lua.LNumber) lua.LNumber

OptNumber returns the nth argument as a number, or d if the argument is nil.

func (State) OptString added in v0.6.0

func (s State) OptString(n int, d string) string

OptString returns the nth argument as a string, or d if the argument is nil.

func (State) OptTable added in v0.6.0

func (s State) OptTable(n int, d *lua.LTable) *lua.LTable

OptTable returns the nth argument as a table, or d if the argument is nil.

func (State) OptUserData added in v0.6.0

func (s State) OptUserData(n int, d *lua.LUserData) *lua.LUserData

OptUserData returns the nth argument as a userdata, or d if the argument is nil.

func (State) Pull added in v0.3.0

func (s State) Pull(n int, t string) types.Value

Pull gets from s.L the values starting from n, and reflects a value from them according to type t registered with s.World.

func (State) PullAnyOf added in v0.3.0

func (s State) PullAnyOf(n int, t ...string) types.Value

PullAnyOf gets from s.L the values starting from n, and reflects a value from them according to any of the types in t registered with s.World. Returns the first successful reflection among the types in t. If no types succeeded, then a type error is thrown.

func (State) PullAnyOfOpt added in v0.7.0

func (s State) PullAnyOfOpt(n int, t ...string) types.Value

PullAnyOfOpt gets from s.L the values starting from n, and reflects a value from them according to any of the types in t registered with s.World. Returns the first successful reflection among the types in t. If no types succeeded, then nil is returned.

func (State) PullArrayOf added in v0.5.0

func (s State) PullArrayOf(n int, t string) rtypes.Array

PullArrayOf pulls an rtypes.Array from n, ensuring that each element is reflected according to t.

func (State) PullDictionaryOf added in v0.5.0

func (s State) PullDictionaryOf(n int, t string) rtypes.Dictionary

func (State) PullFromTable added in v0.4.0

func (s State) PullFromTable(table *lua.LTable, field lua.LValue, t string) types.Value

PullFromTable gets a value from table[field], and reflects a value from it to type t registered with s.World.

func (State) PullFromTableOpt added in v0.4.0

func (s State) PullFromTableOpt(table *lua.LTable, field lua.LValue, t string, d types.Value) types.Value

PullFromTableOpt gets a value from table[field], and reflects a value from it to type t registered with s.World. If the value is nil, d is returned instead.

func (State) PullOpt added in v0.3.0

func (s State) PullOpt(n int, t string, d types.Value) types.Value

PullOpt gets from s.L the value at n, and reflects a value from it according to type t registered with s.World. If the value is nil, d is returned instead.

func (State) Push added in v0.3.0

func (s State) Push(v types.Value) int

Push reflects v according to its type as registered with s.World, then pushes the results to s.L.

func (State) PushArrayOf added in v0.5.0

func (s State) PushArrayOf(t string, v rtypes.Array) int

PushArrayOf pushes an rtypes.Array, ensuring that each element is reflected according to t.

func (State) PushDictionaryOf added in v0.5.0

func (s State) PushDictionaryOf(n int, t string, v rtypes.Dictionary) int

func (State) PushToTable added in v0.4.0

func (s State) PushToTable(table *lua.LTable, field lua.LValue, v types.Value)

PushToTable reflects v according to its type as registered with s.World, then sets the result to table[field]. The type must be single-value. Does nothing if v is nil.

func (State) RaiseError added in v0.3.0

func (s State) RaiseError(format string, args ...interface{}) int

RaiseError is a shortcut for LState.RaiseError that returns 0.

func (State) ReflectorError added in v0.6.0

func (s State) ReflectorError(n int) int

ReflectorError raises an error indicating that a reflector pushed or pulled an unexpected type. Under normal circumstances, this error should be unreachable.

func (State) TypeError added in v0.6.0

func (s State) TypeError(n int, want, got string) int

TypeError raises an argument type error depending on the state's frame type.

func (State) TypeofArg added in v0.7.0

func (s State) TypeofArg(n int) string

TypeOfArg returns the result of World.Typeof with the given argument.

type Symbols added in v0.7.0

type Symbols map[rtypes.Symbol]Property

Symbols is a set of properties keyed by symbol.

type TypeError added in v0.3.0

type TypeError struct {
	Want string
	Got  string
}

typeError is an error where a type was received where another was expected.

func (TypeError) Error added in v0.6.0

func (err TypeError) Error() string

Error implements the error interface.

type World added in v0.3.0

type World struct {
	Global

	Client *Client
	FS     sfs.FS
	// contains filtered or unexported fields
}

World contains the entire state of a Lua environment, including a Lua state, and registered Reflectors, Formats, and Sources.

func NewWorld added in v0.3.0

func NewWorld(l *lua.LState) *World

NewWorld returns a World initialized with the given Lua state.

func (*World) DoFile added in v0.3.0

func (w *World) DoFile(fileName string, args int) error

DoFile executes the contents of the file at fileName as Lua. args is the number of arguments currently on the stack that should be passed in. The file is marked as actively running, and is unmarked when the file returns.

func (*World) DoFileHandle added in v0.3.0

func (w *World) DoFileHandle(f fs.File, name string, args int) error

DoFile executes the contents of file f as Lua. args is the number of arguments currently on the stack that should be passed in. The file is marked as actively running, and is unmarked when the file returns.

func (*World) DoString added in v0.3.0

func (w *World) DoString(s, name string, args int) (err error)

DoString executes string s as Lua. args is the number of arguments currently on the stack that should be passed in.

func (*World) Expand added in v0.6.0

func (w *World) Expand(path string) string

Expand expands a string containing predefined variables.

func (*World) Ext added in v0.3.0

func (w *World) Ext(filename string) (ext string)

Ext returns the extension of filename that most closely matches the name of a registered format. Returns an empty string if no format was found.

func (*World) Format added in v0.3.0

func (w *World) Format(name string) Format

Format returns the Format registered with the given name. If the name is not registered, then Format.Name will be an empty string.

func (*World) Formats added in v0.3.0

func (w *World) Formats() []Format

Formats returns a list of registered formats.

func (*World) MergeTables added in v0.3.0

func (w *World) MergeTables(dst, src *lua.LTable, name string) error

MargeTables merges src into dst according to name. If name is empty, then each key in src is set in dst. If dst[name] is a table, then each key in src is set in that table. If dst[name] is nil, then it is set directly to src. Does nothing if src or dst is nil. Returns an error if the tables could not be merged.

func (*World) MustReflector added in v0.6.0

func (w *World) MustReflector(name string) Reflector

MustReflector returns the Reflector registered with the given name. If the name is not registered, then MustReflector panics.

func (*World) Open added in v0.3.0

func (w *World) Open(lib Library) error

Open opens lib, then merges the result into the world's global table using the ImportedAs field as the name. If the name is already present and is a table, then the table of lib is merged into it, preferring the values of lib. If the name is an empty string, then lib is merged into the global table itself. An error is returned if the merged value is not a table.

func (*World) PeekFile added in v0.3.0

func (w *World) PeekFile() (entry FileEntry, ok bool)

PeekFile returns the info of the currently running file. Returns false if there is no running file.

func (*World) PopFile added in v0.3.0

func (w *World) PopFile()

PopFile unmarks the currently running file. If the last file on the stack is popped, the file's directory is removed as a root from w.FS.

func (*World) PullFrom added in v0.3.0

func (w *World) PullFrom(t string, lvs ...lua.LValue) (v types.Value, err error)

PullFrom reflects lvs to v using registered type t.

func (*World) PushFile added in v0.3.0

func (w *World) PushFile(entry FileEntry) error

PushFile marks a file as the currently running file. Returns an error if the file is already running. If the file is the first file pushed, its directory is added as a root to w.FS.

func (*World) PushTo added in v0.3.0

func (w *World) PushTo(t string, v types.Value) (lvs []lua.LValue, err error)

PushTo reflects v to lvs using registered type t.

func (*World) Reflector added in v0.3.0

func (w *World) Reflector(name string) Reflector

Reflector returns the Reflector registered with the given name. If the name is not registered, then Reflector.Name will be an empty string.

func (*World) Reflectors added in v0.3.0

func (w *World) Reflectors(flags ReflectorFlags) []Reflector

Reflectors returns a list of reflectors that have all of the given flags set.

func (*World) RegisterFormat added in v0.3.0

func (w *World) RegisterFormat(f Format)

RegisterFormat registers a format. Panics if the format is already registered.

func (*World) RegisterReflector added in v0.3.0

func (w *World) RegisterReflector(r Reflector)

RegisterReflector registers a reflector. If the reflector produces a metatable, then it is added as a type metatable to the world's state. Panics if the reflector is already registered.

func (*World) RootDir added in v0.5.0

func (w *World) RootDir() string

RootDir returns the directory of the first file pushed onto the running file stack. Returns an empty string if there are no files on the stack, or the absolute path of the file could not be determined.

func (*World) Split added in v0.6.0

func (w *World) Split(path string, components ...string) ([]string, error)

Split returns the components of a file path.

func (*World) State added in v0.3.0

func (w *World) State() *lua.LState

State returns the underlying Lua state.

func (*World) TempDir added in v0.5.0

func (w *World) TempDir() string

TempDir returns a directory used for temporary files, which is unique per world. Returns an empty string if a temporary directory could not be found.

func (*World) Typeof added in v0.6.0

func (w *World) Typeof(v lua.LValue) string

Typeof returns the type of the given Lua value. If it is a userdata, Typeof attempts to get the type according to the value's metatable. Panics if v is nil (not if nil Lua value).

func (*World) UserDataCacheLen added in v0.3.0

func (w *World) UserDataCacheLen() int

UserDataCacheLen return the number of userdata values in the cache.

func (*World) UserDataOf added in v0.3.0

func (w *World) UserDataOf(v types.Value, t string) *lua.LUserData

UserDataOf returns the userdata value associated with v. If there is no such userdata, then a new one is created, with the metatable set to the type corresponding to t.

v must be comparable.

func (*World) WrapFunc added in v0.3.0

func (w *World) WrapFunc(f func(State) int) *lua.LFunction

WrapFunc wraps a function that receives a State into a Lua function.

func (*World) WrapMethod added in v0.6.0

func (w *World) WrapMethod(f func(State) int) *lua.LFunction

WrapMethod is like WrapFunc, but marks the state as being a method.

func (*World) WrapOperator added in v0.6.0

func (w *World) WrapOperator(f func(State) int) *lua.LFunction

WrapOperator is like WrapFunc, but marks the state as being an operator.

Directories

Path Synopsis
Tool to increment the version number, read and write rbxmk/version.go, then create and tag a commit.
Tool to increment the version number, read and write rbxmk/version.go, then create and tag a commit.
The dump package describes Lua APIs.
The dump package describes Lua APIs.
dt
The dt package describes the types of Lua API items.
The dt package describes the types of Lua API items.
The fragments package contains translations of documentation fragments.
The fragments package contains translations of documentation fragments.
term
The term package implements a goldmark renderer for rendering Markdown in the terminal.
The term package implements a goldmark renderer for rendering Markdown in the terminal.
The sfs package providing a secure file system, with access limitations.
The sfs package providing a secure file system, with access limitations.

Jump to

Keyboard shortcuts

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