buffer

사용되지 않는 항목 표시

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.

요약

함수

함수

create

매개 변수

size: number

반환

fromstring

매개 변수

str: string

반환

tostring

매개 변수

반환

매개 변수

반환

readi8

매개 변수

offset: number

반환

readu8

매개 변수

offset: number

반환

readi16

매개 변수

offset: number

반환

readu16

매개 변수

offset: number

반환

readi32

매개 변수

offset: number

반환

readu32

매개 변수

offset: number

반환

readf32

매개 변수

offset: number

반환

readf64

매개 변수

offset: number

반환

writei8

void

매개 변수

offset: number
value: number

반환

void

writeu8

void

매개 변수

offset: number
value: number

반환

void

writei16

void

매개 변수

offset: number
value: number

반환

void

writeu16

void

매개 변수

offset: number
value: number

반환

void

writei32

void

매개 변수

offset: number
value: number

반환

void

writeu32

void

매개 변수

offset: number
value: number

반환

void

writef32

void

매개 변수

offset: number
value: number

반환

void

writef64

void

매개 변수

offset: number
value: number

반환

void

readstring

매개 변수

offset: number
count: number

반환

writestring

void

매개 변수

offset: number
value: string
count: number

반환

void

copy

void

매개 변수

target: buffer
targetOffset: number
source: buffer
sourceOffset: number
기본값: 0
count: number

반환

void

fill

void

매개 변수

offset: number
value: number
count: number

반환

void