godot-binary-serialization

0.1.6 • Public • Published

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
  • [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

License

MIT license

Readme

Keywords

none

Package Sidebar

Install

npm i godot-binary-serialization

Weekly Downloads

10

Version

0.1.6

License

MIT

Unpacked Size

94 kB

Total Files

79

Last publish

Collaborators

  • fulkman