Code Monkey home page Code Monkey logo

defold-protobuf's Introduction

Defold-Protobuf

Defold-Protobuf Native Extension for the Defold Game Engine

This extension allow you work with google protobuf protocol (files .proto), encode and decode them.

Platforms

  • iOS
  • Android
  • MacOS
  • Windows

Setup

You can use the Defold-Protobuf extension in your own project by adding this project as a Defold library dependency. Open your game.project file and in the dependencies field under project add:

https://github.com/Melsoft-Games/defold-protobuf/archive/master.zip

Or point to the ZIP file of a specific release.

Short API:

local protoc = require("pb.protoc")

protoc:loadfile("resources/test.proto")
local data = {
	values = {
		first = {
		number = 1.5,
		unumber = 20,
		string = "hello"
	}
}

-- some.Example - name of message from test.proto
local bytes = pb.encode("some.Example", data)
local unpackage = pb.decode("some.Example", bytes)

API

protoc - lua module to parse proto files

This part of docs from lua-protobuf README

Function Returns Descriptions
protoc.reload() true reload all google standard messages into pb module
protoc:parse(string) table transform schema to DescriptorProto table
protoc:parsefile(string) table like protoc:parse(), but accept filename
protoc:compile(string) string transform schema to binary *.pb format data
protoc:compilefile(string) string like protoc:compile(), but accept filename
protoc:load(string) true load schema into pb module
protoc:loadfile(string) true like pb:loadfile(), but accept filename (you can point file from custom resouces in Defold)
protoc.loaded table contains all parsed DescriptorProto table
protoc.paths table a table contains import search directories
protoc.unknown_module see below handle schema import error
protoc.unknown_type see below handle unknown type in schema
protoc.include_imports bool auto load imported proto

pb - native extension symbol

pb.encode(message_name, data)

returns bytes of lua table data. Data should be match to proto description message_name If proto file has package {name}; message_name will be {name}.{message_name}

pb.decode(message_name, bytes)

returns lua table from bytes. Bytes should be match to proto description message_name

Full README to pb and protoc read here

License, Authors

MIT license This NE wrapped by AKashpur

Original module: lua-protobuf

Issues and suggestions

If you have any issues, questions or suggestions please create an issue or contact me: [email protected]

defold-protobuf's People

Contributors

insality 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.