Read data from a buffer at the given position.


buffer_peek(buffer, offset, type);

Argument Description
buffer The index of the buffer to use.
offset 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


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.

Back: Buffers
Next: buffer_poke
© Copyright YoYo Games Ltd. 2015 All Rights Reserved