buffer

Afficher les obsolètes

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.

Résumé

Fonctions

Fonctions

create

Paramètres

size: number

Retours

fromstring

Paramètres

str: string

Retours

tostring

Paramètres

Retours

Paramètres

Retours

readi8

Paramètres

offset: number

Retours

readu8

Paramètres

offset: number

Retours

readi16

Paramètres

offset: number

Retours

readu16

Paramètres

offset: number

Retours

readi32

Paramètres

offset: number

Retours

readu32

Paramètres

offset: number

Retours

readf32

Paramètres

offset: number

Retours

readf64

Paramètres

offset: number

Retours

writei8

void

Paramètres

offset: number
value: number

Retours

void

writeu8

void

Paramètres

offset: number
value: number

Retours

void

writei16

void

Paramètres

offset: number
value: number

Retours

void

writeu16

void

Paramètres

offset: number
value: number

Retours

void

writei32

void

Paramètres

offset: number
value: number

Retours

void

writeu32

void

Paramètres

offset: number
value: number

Retours

void

writef32

void

Paramètres

offset: number
value: number

Retours

void

writef64

void

Paramètres

offset: number
value: number

Retours

void

readstring

Paramètres

offset: number
count: number

Retours

writestring

void

Paramètres

offset: number
value: string
count: number

Retours

void

copy

void

Paramètres

target: buffer
targetOffset: number
source: buffer
sourceOffset: number
Valeur par défaut : 0
count: number

Retours

void

fill

void

Paramètres

offset: number
value: number
count: number

Retours

void