Powder Toy Lua API

From The Powder Toy
Jump to: navigation, search
Language: English  • 한국어 • 中文

The Powder Toy Lua API is a set of objects and functions that allow control over most aspects of the game, including graphics, element interactions, and interfaces.

If you are new to the Lua programming language, you should familiarize yourself with how to code in Lua. A great beginner's tutorial is available here

If you are using an editor that supports the Language Server Protocol like VSCode, you can get completions for the lua API here

The API is split into several categories

Methods for modifying the state of the simulation.
Methods and constants for modifying and creating elements.
Methods for drawing simple shapes and text on the screen.
Methods and constants for interacting with the display mode.
Listen for events, such as mouse clicks or key presses.
Includes UI components such as buttons, labels, and checkboxes, access to the very primitive window manager, and input events.
File System
Functions for creating, deleting, modifying, and enumerating files and folders.
Functions for doing OS-level things like opening URLs or interacting with the clipboard.
Provides TCP sockets, effectively a severely feature-limited version of the LuaSocket library
Provides access to basic HTTP functionality in the form of request objects.
Provides direct access to our bzip2 library, for compressing and decompressing data.
Doesn't actually provide any interaction with the game, but provides some functions for performing bitwise operations on integer numbers.
Old Lua API with the tpt.* prefix