1. Install python runtime and the protobuf 2.3 for python.

  2. Checkout the code hg clone

  3. Install the Lua module

    $ cd protobuf/ $ luarocks make #optionally with sudo

  4. Make a link to protoc-gen-lua in your $PATH:

    $cd /usr/local/bin && sudo ln -s /path/to/protoc-gen-lua/plugin/protoc-gen-lua

  5. Then you can compile the .proto like this:

    protoc --lua_out=./ foo.proto

Quick Example

You write a .proto file like this:

person.proto : message Person { required int32 id = 1; required string name = 2; optional string email = 3; }

Then you compile it using protoc --lua_out=./ person.proto. This will generate a file called person_pb.lua. You can use it in your Lua script like that:

require "person_pb"

-- Serialize Example
local msg = person_pb.Person() = 100 = "foo" = "bar"
local pb_data = msg:SerializeToString()

-- Parse Example
local msg = person_pb.Person()

The API of this library is similar the protobuf library for python. For a more complete example, read the python protobuf documentation.