0.1.6 • Published 2 years ago

godot-binary-serialization v0.1.6

Weekly downloads
1
License
MIT
Repository
github
Last release
2 years ago

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.

Build Status

NPM

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
  • Signed Int (8-/16-/32-/64-bits)
  • Unsigned Int (8-/16-/32-/64-bits)
  • Real (float/double)
  • String

Already Supported

atomic types

math types

misc types

arrays

License

MIT license

0.1.6

2 years ago

0.1.5

3 years ago

0.1.4

4 years ago

0.1.3

6 years ago