👑
Impulse documentation
  • Getting started
  • Examples
    • Console
    • Window
  • enviornment
    • Globals
      • Lua globals
      • Impulse globals
    • Libraries
      • Win32
      • Direct X
      • Renderer
      • Input
      • Crypt
      • Memory
      • File system
      • Debug
  • Enumerations
    • Key codes
    • Cursor style
    • Primitive topology
  • Data types
    • Vector2
    • Vector3
    • Vertex
    • Color
    • Draw command
Powered by GitBook

Impulse links

  • GitHub
  • Project
  • Discord

© 2025 Impulse

On this page
  • assert
  • error
  • gcinfo
  • getmetatable
  • ipairs
  • newproxy
  • next
  • pairs
  • pcall
  • print
  • rawequal
  • rawget
  • rawlen
  • rawset
  • require
  • select
  • setmetatable
  • tonumber
  • tostring
  • type
  • unpack
  • xpcall
  1. enviornment
  2. Globals

Lua globals

The following is a list of functions and variables that are native to Lua. These functions can be used in a standard installation of Lua 5.1.4, though there are some differences in how some work.

assert

assert(value: boolean, error_message: string) -> nil

Throws an error if the provided value is false or nil, stopping execution and displaying the provided error message.

error

error(message: string, level: number) -> nil

Immediately halts execution and throws an error with the given message and optional stack level.

gcinfo

gcinfo() -> number

Returns the current memory usage in kilobytes, providing insight into Lua's garbage collection.

getmetatable

getmetatable(t: table) -> table | nil

Retrieves the metatable of the given table, or nil if no metatable exists.

ipairs

ipairs(t: table) -> function, table, number

Returns an iterator function for sequentially iterating over an array-like table in order.

newproxy

newproxy(add_metatable: boolean) -> userdata

Creates a blank userdata object, optionally with a metatable for custom behavior.

next

next(t: table, last_key: any) -> any, any

Returns the next key-value pair in a table, allowing iteration when used in a loop.

pairs

pairs(t: table) -> function, table

Returns an iterator function for traversing all key-value pairs in a table, including non-sequential keys.

pcall

pcall(func: function, ...: any) -> boolean, any

Calls a function safely, returning true and the result if successful, or false and an error message if an error occurs.

print

print(...: any) -> nil

Outputs the provided values to the console for debugging or display purposes.

rawequal

rawequal(v1: any, v2: any) -> boolean

Compares two values for equality, ignoring metamethods such as __eq.

rawget

rawget(t: table, index: any) -> any

Directly retrieves a value from a table, bypassing any __index metamethods.

rawlen

rawlen(t: table) -> number

Returns the length of a table or string without invoking metamethods.

rawset

rawset(t: table, index: any, value: any) -> nil

Directly assigns a value to a table, bypassing any __newindex metamethods.

require

require(module: string | number) -> any

Loads and runs a module script, returning its result if it has already been executed.

select

select(index: number, ...: any) -> any

Returns all arguments after the specified index, or the total argument count if the index is "#".

setmetatable

setmetatable(t: table, new_meta: table) -> table

Assigns a new metatable to the given table, enabling custom behaviors like operator overloading.

tonumber

tonumber(arg: any, base: number) -> number | nil

Converts a value to a number, optionally using a specified base, or returns nil if conversion fails.

tostring

tostring(value: any) -> string

Converts a value into a string representation, typically used for debugging or display.

type

type(value: any) -> string

Returns a string representing the type of the given value, such as number, string, or table.

unpack

unpack(list: table, i: number, j: number) -> ...any

Returns multiple values from a table, from index i to j, effectively "unpacking" them.

xpcall

xpcall(func: function, err: function, ...: any) -> boolean, any
PreviousGlobalsNextImpulse globals

Last updated 3 months ago

Similar to , but allows for a custom error handler function to process errors before they are returned.

pcall