The Core Library

The core library is all the code that Metis requires to function at runtime. All the modules in this library are loaded by default when Metis starts up.

The Core Functions

globals(): table

Returns the global environment table.

input(prompt: string | null): string

Takes a string prompt, prints it to the console, and then waits for the user to enter a line of text. If the prompt is null, then no prompt is printed. Returns the line of text entered by the user.

iter(value: any): any

Returns an iterator for the given value. Requires the __iter__ metamethod to be defined on the value. The iterator must have the hasNext(self): boolean and the next(self): any methods defined.

loadChunk(name: string, chunk: string): callable

Loads the given Metis code as a callable function. Returns the function.

print(value: any): null

Prints the value to the console, followed by a newline.

str(value: any): string

Converts the value to a string. Requires the __str__ metamethod to be defined on the value.

type(value: any): string

Returns the type of the value as a string. Can be one of the following:

withMetatable(value: any, metatable: table): any

Sets the metatable of the value to the given table, and returns the value.

yield(value: any): null

Yields the value to the parent.

The Core Fields

false: boolean

The boolean value false.

null: null

The null value null.

true: boolean

The boolean value true.

The Core Modules

boolean

Provides functions for working with booleans. Also the boolean metatable.

bytes

Provides functions for working with bytes. Also the bytes metatable.

collection

Provides functions for working with collections. Also the metatable for strings and lists.

coroutine

Provides functions for working with coroutines. Also the coroutine metatable.

io

Provides functions for working with input and output streams.

list

Provides functions for working with lists. Also the list metatable.

number

Provides functions for working with numbers. Also the number metatable.

package

Provides the infrastructure for loading modules.

range

Provides functions for working with ranges. Also the range metatable.

string

Provides functions for working with strings. Also the string metatable.

table

Provides functions for working with tables. Also the table metatable.