buffer_peek

语法:

buffer_peek(buffer, offset, type);


参数 描述
buffer The index of the buffer to use.
偏移 The offset position (in bytes) within the buffer to read the given data from.
type The type of data that is to be read from the buffer (see the list of constants here).


Returns: Real/String or one of the following constants if it fails:

常量 描述
buffer_outofspace is returned when peeking / poking to a buffer beyond its capacity
buffer_outofbounds is when an explicit operation is outside of the buffer capacity (i.e. index is < 0 or > capacity)
buffer_invalidtype is when a non u8 type is used for peeking from a fast buffer type.


描述

With the buffer_read function, you can read data from the given buffer at the current "seek" position, with each piece of data being read advancing this position by the bytes being read or written. However, it may be necessary for you to read a given piece of data without wanting to change the current seek position, and that's when you would use this function. You simply supply the function with a buffer id, and then an offset position (from the buffer start) within that buffer to read from, as well as the data type that you are wanting to read.

NOTE: Using the incorrect data type for the data being read will result in erroneous values!


例如:

var red = buffer_peek(buff, 1, buffer_u8);
var green = buffer_peek(buff, 2, buffer_u8);
var blue = buffer_peek(buff, 3, buffer_u8);
image_blend = make_colour_rgb(red, green, blue);

The above code will get three values from three different positions within the buffer indexed in the variable "buff" and then use those values to set the image blend of the instance.