Skip to main content

BT standard library

The packages every BT program can use, in games and tools alike: printing, text, math, files, time, networking and more. Include a package by its name, for example include "io";, to use its functions and types.

The engine's own packages are in the cTurtle API reference.

Functions and methods can fail unless marked infallible; handle a failure with ? or !! (see Errors).

PackageContents
bufferGrowable byte storage for building, parsing, reading and writing binary data.
filesRead and write files, and list, create and remove directories.
ioPrint text to the console, and read or write the program's standard input, output and error streams.
jsonRead JSON documents and look up their values by path (JSON Pointer, such as "/player/name").
mathMath on floats: square roots, powers, logarithms, trigonometry, rounding, minimum and maximum, and checks for infinity and NaN.
processRun other programs, read the program's command-line arguments and environment variables, and resolve and inspect paths.
regexRegular expressions: compile a pattern once, then find matches and their captured groups in text.
socketTCP network connections: connect to a server or listen for clients, then send and receive bytes.
stringText: the methods every string has (length, slicing, searching), and conversion between strings, numbers and buffers.
syncA lock for tasks that share data, so only one task changes it at a time.
timeClocks and timers: wait for a while, measure how much time has passed, and read the current UTC date and time.