GameMaker (2.3)

Buffer Parser

Eduardo Machado

You must be logged in to obtain assets


This is a buffer parser inspired by the Node.JS "binary-parser" package.

By using it, you can create templates to parse your buffers and can be extremely useful when handling network messages.


First, you need to create the required parser templates:

var header_parser = new parser()._uint8("command");
var join_game_parser = new 
var login_parser = new parser()._skip(1)._strictstring("username")._strictstring("password");

(you can add as many parsing elements as you need)

(the endian element will set the endianess for all the following 2-more bytes numbers read and will require 1 argument - true for little endian and false for big endian)

(as default, GameMaker will write buffers using the little endian format)

Then you can call the "parse(buffer)" function to get the result object:

var result = join_game_parser.parse(buf);
var result = login_parser.parse(buf);


{ room : "rm_first_map", conditions : [ 1,1,1,0,0 ], posx : 12458, posy : 3596, username : "player 1", _valid : 1 }
{ password : "mysecretpassword", username : "player 1", _valid : 1 }

The difference between "strictstring" and "string" is that "strictstring" will only accept "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789,./\<>?;':\"|[]{}[email protected]#$%&()-=_+áÁéÉíÍóÓúÚàÀèÈìÌòÒùÙäÄëËïÏöÖüÜâÂêÊîÎôÔûÛãÃõÕ " as valid characters and will return an invalid object ("_valid = false") if any invalid character is found.

The valid elements are:

_array(name,length,datatype,stringbufferlimit or -1,_surfw if surface,_surfh if surface){
_buffer(name,size or -1) **new**
_surface(name,surfw,surfh) **new**


**0.0.2: Huge update!**

You can now parse buffers and surfaces.
You can now use previously read elements as a valid value for array size, string limit, buffer size, surface width and 
surface height. (*p = new parser()._uint16("surfw")._uint16("surfh")._surface("element","surfw","surfh"); //SURFACE WILL USE THE READ VALUES FROM "SURFW" AND "SURFH" AS PARAMETERES*)


Parsed object now returns the "_position", showing the next byte to be read on the buffer

End User Licence Agreement (EULA).

Age Rating: 4+


GMS2.3 - Version 0.0.2. Published April 20, 2022

Huge update - added support for named variables and buffer and surface as elements

Loading, please wait

Package contents

Loading, please wait

What is the issue?

Loading, please wait