Libraries
Libraries are collections of functions that can be used to simplify certain tasks or gather all functions for a certain datatype in one place. For example, the table
library is a collection of functions that work with tables, and the math
library is a collection of functions for advanced math, such as random
, cos
, rad
, noise
, ...
A library's function is accessed with a dot, just like instances. For example, to access the function create
of the library table
, I would do it this way: table.create()
.
Out of the box, Powerlang comes with five libraries: math
, string
, table
, retrostudio
and compiler
. In this guide we will go over the first four, as you likely won't need the compiler
library (but if you do, check out Compiler Library).
Unlike in Lua, libraries are abstract. This means you cannot do anything with libraries aside from calling their functions. You cannot add your own functions, you cannot reassign the library variable, you cannot loop through it, etc. This is because library variables do not exist during runtime, and all library calls are processed at the compiler level.
Advanced Math with math
math
The math
library is a nearly 1:1 port of Roblox's math library: https://create.roblox.com/docs/reference/engine/libraries/math
Due to this, you are advised to check out the Roblox documentation for the library instead.
String Operations with string
string
The string
library makes working with strings easier. It has similarities to Roblox's string library, but is not a 1:1 port.
The string
library supports the following functions: split
, find
, sub
, gsub
, length
, upper
, lower
and filter
. You can find out more in its respective documentation: string.
Table Operations with table
table
The table
library, as you could've already guessed, works with tables (primarily arrays, not dictionaries).
The library supports: create
, append
, insert
, remove
, find
, sort
, and length
. You've learned some of these in Tables. Check out its documentation for more information: table
Special Blocks with retrostudio
retrostudio
The retrostudio
library was made for blocks in the "Misc" section of the "Misc" tab in Visual Scripting/Block Coding. As you can tell by the official categorization, these cannot be put into any reasonable category, therefore a separate library has been created for them.
You can find all available functions and their descriptions here: retrostudio
The next page is the final page of this guide, where you'll learn comments and flags.
Last updated