Buffers in GameMaker are a way of storing binary data in a block of memory, which could be used for various purposes such as saving/loading files, sending/receiving data over a network, or manipulating large arrays of data more efficiently than with standard arrays.
A buffer can hold different types of data (like strings, integers, and floats) and allows you to control how that data is read and written on a byte-by-byte level, which is useful when dealing with file formats or protocols that GameMaker doesn't natively support.
Here's a basic example of creating a buffer, writing some data to it, and then reading it back:
In this example, we created a fixed-size buffer with a capacity of 256 bytes, wrote an unsigned 8-bit integer and a 32-bit float to it, and then read those values back. Notice how we use
buffer_seek to set the read/write position in the buffer before performing operations.
Buffer functions include
buffer_seek, and many others to manipulate the data within.