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