Giter Club home page Giter Club logo

du-serializer's Introduction

du-serializer

Tests

A Lua library to serialize table in string in Dual Universe to improve performances and reduce size to store data in databanks or for transmissions.

Documentation

serialize(table t)

Serialize a table t and return a string. Tables and arrays are supported, not mixed table. See serializer_spec.lua for supported and unsupported cases.

deserialize(string s)

Deserialize a serialized table as string s and return the table.

Benchmark

Following graphs are the results of the benchmark, encoding and decoding a simple test table in bench.lua multiple times. Dkjson is a popular JSON encoding/decoding library in Lua, which is embedded by default in Dual Universe. Pure Lua Json, is a compact pure-Lua alternative library for JSON encoding/decoding, can be found at json.lua 0.1.2, created by Rxi.

This benchmark has been done in Dual Universe, on a clean programming board. The missing data for the dkjson and pure lua json is due to the fact it trigger the CPU OVERLOAD error in the game.

*Benchmark updated the 09/25/2021.*

How to use

To use this library in Dual Universe, you can simply copy the lua code and paste it in a Library slot. It can be used to compute transmissions for the du-socket library. See below an example :

local player = {
  id = 999,
  name = "Username",
  pos = { 1, 2, 3},
  org = "Org name",
  relation = 0
}

local s = serialize(player) -->  {relation=0,org="Org name",pos={1,2,3},id=999,name="Username"}
local t = deserialize(s)
print(t.name) --> Username

Keep in mind that for Lua-keyed tables, they are not ordered. However, ordinary arrays using integer indexes are ordered. (As seen in the above example, the pos data within that field will be ordered, but the position that the pos key takes will not.)

Credits

Thanks to Arialia for her collaboration from the game organization Silentium

du-serializer's People

Contributors

1337joe avatar easterngamer avatar eliasvilld avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.