# Lua Protobuf (libraries from luarocks)

**URL:** <https://forum.defold.com/t/lua-protobuf-libraries-from-luarocks/2434>\
**Category:** Questions\
**Created:** [July 16, 2016, 8:00am UTC](https://forum.defold.com/t/lua-protobuf-libraries-from-luarocks/2434 "2016-07-16T08:00:22Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![Insality](https://forum-defold.b-cdn.net/user_avatar/forum.defold.com/insality/32/39737_2.png) [@Insality](https://forum.defold.com/u/Insality)\
**Post date:** [July 16, 2016, 8:00am UTC](https://forum.defold.com/t/lua-protobuf-libraries-from-luarocks/2434/1 "2016-07-16T08:00:22Z")

</div>

Hello!  
Im trying to using protobuf in my game and founded some libraries to do it ( [GitHub - Neopallium/lua-pb: Lua Protocol Buffers · GitHub](https://github.com/Neopallium/lua-pb), [GitHub - djungelorm/protobuf-lua: Lua library for Google's Protocol Buffers · GitHub](https://github.com/djungelorm/protobuf-lua)). There is way to install it and using in my game?  
Seems need to use luarocks package manager. Can i do it and how? (windows)

---

<div class="post-metadata">

**Author:** ![britzl](https://forum-defold.b-cdn.net/user_avatar/forum.defold.com/britzl/32/23_2.png) [@britzl](https://forum.defold.com/u/britzl)\
**Post date:** [July 16, 2016, 11:28am UTC](https://forum.defold.com/t/lua-protobuf-libraries-from-luarocks/2434/2 "2016-07-16T11:28:13Z")

</div>

LuaRocks is a conventient way to download a Lua library and it’s dependencies. It can be done by hand as well.

In order to include Lua libraries you need to have them accessible from the root folder or a subfolder of your project. You cannot load modules from other sources (well, maybe using loadfile, but that won’t be cross platform).

You can only use pure Lua libraries. Many Lua libraries include a C lib as well. This seems to be the case with the second protobuf library. The first one (lua-pb) should be fine though.

Summary: Download the library source code and any dependencies and put the files in your project. Lua modules can then be included and used in your scripts using the `require()` function.

---

<div class="post-metadata">

**Author:** ![Insality](https://forum-defold.b-cdn.net/user_avatar/forum.defold.com/insality/32/39737_2.png) [@Insality](https://forum.defold.com/u/Insality)\
**Post date:** [July 16, 2016, 11:46am UTC](https://forum.defold.com/t/lua-protobuf-libraries-from-luarocks/2434/3 "2016-07-16T11:46:26Z")

</div>

Thanks for answer! I will try more but there is a problem:  
A lot of libraries what I found, depends of some libraries on C language, so, as i am undestand, i can’t use them?  
lua-pb depends from the c-lib, as I know now.

**edit:** ok. i cannot use any of these pb libraries (dependecies :(). What I can do to work with protobufs in defold?

And in this forum post: [Defold 1.2.81 has been released](https://forum.defold.com/t/defold-1-2-81-has-been-released/1865)  
There is line: DEF-1353 - Fixed: GUI protobuf message docs are not included in API docs. What is means? 🙂

---

<div class="post-metadata">

**Author:** ![sicher](https://forum-defold.b-cdn.net/user_avatar/forum.defold.com/sicher/32/8_2.png) [@sicher](https://forum.defold.com/u/sicher)\
**Post date:** [July 16, 2016, 11:51am UTC](https://forum.defold.com/t/lua-protobuf-libraries-from-luarocks/2434/4 "2016-07-16T11:51:05Z")

</div>

The doc update included messages for GUI components: [API reference (GUI)](http://www.defold.com/ref/gui/#layout_changed:id-previous_id)

The engine uses protobuf internally.

---

<div class="post-metadata">

**Author:** ![Insality](https://forum-defold.b-cdn.net/user_avatar/forum.defold.com/insality/32/39737_2.png) [@Insality](https://forum.defold.com/u/Insality)\
**Post date:** [July 19, 2016, 4:52am UTC](https://forum.defold.com/t/lua-protobuf-libraries-from-luarocks/2434/5 "2016-07-19T04:52:35Z")

</div>

So, is it possible to give to users protobuf api?  
Just because I cant see another way to use protobuf in Defold.

---

<div class="post-metadata">

**Author:** ![britzl](https://forum-defold.b-cdn.net/user_avatar/forum.defold.com/britzl/32/23_2.png) [@britzl](https://forum.defold.com/u/britzl)\
**Post date:** [July 19, 2016, 5:54am UTC](https://forum.defold.com/t/lua-protobuf-libraries-from-luarocks/2434/6 "2016-07-19T05:54:58Z")

</div>

It should be possible to create a pure Lua implementation of protobufs. I’m surprised there is none available.

Could I ask why you have chosen to use protobufs?

---

<div class="post-metadata">

**Author:** ![Insality](https://forum-defold.b-cdn.net/user_avatar/forum.defold.com/insality/32/39737_2.png) [@Insality](https://forum.defold.com/u/Insality)\
**Post date:** [July 19, 2016, 6:40am UTC](https://forum.defold.com/t/lua-protobuf-libraries-from-luarocks/2434/7 "2016-07-19T06:40:05Z")

</div>

Pure lua protobuf will be not so fast as needed (the main protobuf advantage), isn’t? Rly dont know about lua speed in this things.

I have choosed pb, because i wanted to work with it and learn it. And pb advantages is very good (speed and size) for network shooter game.

Should I edit this theme to “Feature request?”

---

<div class="post-metadata">

**Author:** ![britzl](https://forum-defold.b-cdn.net/user_avatar/forum.defold.com/britzl/32/23_2.png) [@britzl](https://forum.defold.com/u/britzl)\
**Post date:** [July 19, 2016, 7:54am UTC](https://forum.defold.com/t/lua-protobuf-libraries-from-luarocks/2434/8 "2016-07-19T07:54:28Z")

</div>

LuaJIT which we use in Defold is very fast. Is it fast enough? Probably, but I do not know for sure. What’s the estimated amount of data sent and received every frame? You need to do some benchmarking yourself (and with help from the community here perhaps).
