Difference between revisions of "Powder Toy Lua API"

From The Powder Toy
Jump to: navigation, search
(Reworded for clarity and brevity. To me it sounded like THIS page was the one that was outdated)
(Clarify relation of the socket global to LuaSocket)
Line 25: Line 25:
 
: Listen for events, such as mouse clicks or key presses.
 
: Listen for events, such as mouse clicks or key presses.
 
; [http://w3.impa.br/~diego/software/luasocket/ Socket]
 
; [http://w3.impa.br/~diego/software/luasocket/ Socket]
: Built-in LuaSocket library available as the <code>socket</code> global.
+
: Provides TCP sockets, effectively a severely feature-limited version of the LuaSocket library
 
; [[Lua_API:HTTP|HTTP]]
 
; [[Lua_API:HTTP|HTTP]]
 
: Provides access to basic HTTP functionality in the form of request objects.
 
: Provides access to basic HTTP functionality in the form of request objects.

Revision as of 14:00, 29 November 2023

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

boxmein made a massive reference to most parts of the API, including some that are not added to this wiki yet. However, it is extremely outdated. You can find it here.

The API is split into several categories

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