buffer

Mostrar obsoleto

A buffer is an object that represents a fixed-size mutable block of memory. The buffer library provides functions for creation and manipulation of buffer objects, providing all its functions inside the global buffer variable.

Buffer is intended to be used a low-level binary data storage structure, replacing the uses of string.pack() and string.unpack(). Use cases include reading and writing existing binary formats, working with data in a more compact form, serialization to custom binary formats, and general work with native memory types like fixed-length integers and floats.

When passed through Roblox APIs, including sending a buffer through custom events, the identity of the buffer object is not preserved and the target will receive a copy. Similar to other limitations, the same buffer object cannot be used from multiple Actor scripts (Parallel Luau).

Many of the functions accept an offset in bytes from the start of the buffer. Offset of 0 from the start of the buffer memory block accesses the first byte. All offsets, counts and sizes should be non-negative integer numbers. If the bytes that are accessed by any read or write operation are outside the buffer memory, an error is thrown.

The read and write methods that work with integers and floats use little-endian encoding.

Resumen

Funciones

Funciones

create

Parámetros

size: number

Devuelve

fromstring

Parámetros

str: string

Devuelve

tostring

Parámetros

Devuelve

Parámetros

Devuelve

readi8

Parámetros

offset: number

Devuelve

readu8

Parámetros

offset: number

Devuelve

readi16

Parámetros

offset: number

Devuelve

readu16

Parámetros

offset: number

Devuelve

readi32

Parámetros

offset: number

Devuelve

readu32

Parámetros

offset: number

Devuelve

readf32

Parámetros

offset: number

Devuelve

readf64

Parámetros

offset: number

Devuelve

writei8

void

Parámetros

offset: number
value: number

Devuelve

void

writeu8

void

Parámetros

offset: number
value: number

Devuelve

void

writei16

void

Parámetros

offset: number
value: number

Devuelve

void

writeu16

void

Parámetros

offset: number
value: number

Devuelve

void

writei32

void

Parámetros

offset: number
value: number

Devuelve

void

writeu32

void

Parámetros

offset: number
value: number

Devuelve

void

writef32

void

Parámetros

offset: number
value: number

Devuelve

void

writef64

void

Parámetros

offset: number
value: number

Devuelve

void

readstring

Parámetros

offset: number
count: number

Devuelve

writestring

void

Parámetros

offset: number
value: string
count: number

Devuelve

void

copy

void

Parámetros

target: buffer
targetOffset: number
source: buffer
sourceOffset: number
Valor predeterminado: 0
count: number

Devuelve

void

fill

void

Parámetros

offset: number
value: number
count: number

Devuelve

void