Buffer.copy
Available since: Gideros 2025.1
Class: buffer_luau
Description
Copies count bytes from source starting at offset sourceOffset into the target at targetOffset.
buffer.copy(target,targetOffset,source,sourceOffset,count)
It's possible for source and target to be the same. Copying an overlapping region inside the same buffer acts as if the source region is copied into a temporary buffer and then that buffer is copied over to the target.
Parameters
target: (buffer) buffer to copy data into
targetOffset: (number) offset from the beginning of the buffer memory, starting from 0
source: (buffer) buffer to take the data from
sourceOffset: (number) offset from the beginning of the buffer memory, starting from 0 optional default = 0
count: (number) Number of bytes to copy optional if omitted, the whole source data starting from sourceOffset is taken
Example
local b: buffer = buffer.create(16)
local count = 7
local b2: buffer = buffer.create(count)
local targetOffset, sourceOffset = 0, 2
buffer.copy(b2, targetOffset, b, sourceOffset, count)
print(buffer.tostring(b2))