godot-binary-serialization
v0.1.6
Published
Godot has a simple serialization API based on Variant. It’s used for converting data types to an array of bytes efficiently.
Downloads
27
Readme
Godot Binary Serialization
Godot has a simple serialization API based on Variant. It’s used for converting data types to an array of bytes efficiently.
https://docs.godotengine.org/en/latest/tutorials/io/binary_serialization_api.html (version 3.x)
Quick Start
Install
$ npm install [--save] godot-binary-serialization
Requirements
Godot version 3.0
Basic Usage
UDP
const packetPeer = require('godot-binary-serialization').PacketPeer;
// decode data - receive from Godot Engine
const decoded = packetPeer.get_var(msg);
// encode data - send them to Godot Engine
const encoded = packetPeer.put_var(variant);
TCP
const streamPeer = require('godot-binary-serialization').StreamPeer;
// decode data - receive from Godot Engine
const decoded = streamPeer.get_var(msg);
// encode data - send them to Godot Engine
const encoded = streamPeer.put_var(variant);
It is possible to send/receive single type value into the stream.
// @example - FLOAT type
// decode data - receive from Godot Engine
const decoded = streamPeer.get_float(msg);
// encode data - send them to Godot Engine
const encoded = streamPeer.put_float(variant);
Available
- [x] Signed Int (8-/16-/32-/64-bits)
- [x] Unsigned Int (8-/16-/32-/64-bits)
- [x] Real (float/double)
- [x] String
Already Supported
atomic types
math types
misc types
arrays
- [ ] POOL_BYTE_ARRAY
- [ ] POOL_INT_32_ARRAY
- [ ] POOL_INT_64_ARRAY
- [ ] POOL_FLOAT_32_ARRAY
- [ ] POOL_FLOAT_64_ARRAY
- [ ] POOL_STRING_ARRAY
- [ ] POOL_VECTOR2_ARRAY
- [ ] POOL_VECTOR3_ARRAY
- [ ] POOL_COLOR_ARRAY
License
MIT license