How can we install Lua modules with LuaRocks?

Hello, I want to use FlatBuffers to send data with lua.
This is FlatBuffers library:

However, nakama lua runtime is Lua5.1. We need to install modules like compat53 (For Lua5.3 string.pack, etc.) for FlatBuffers.
I think we can use luarocks to install to run FlatBuffers on nakama lua runtime. How can we install dependencies module on nakama lua runtime with luarocks? Or do we need to import like compat53 library to data/modules to let FlatBuffers work?

Thanks!

Hi @Tsen we’d recommend installing a local Lua 5.1 and LuaRocks setup, installing your required packages and copying the Lua files to your server project.

In addition to what Sean mentioned - FlatBuffers with Lua won’t work in Nakama as it has native/c bindings, and the Lua VM shipped in Nakama is a virtual one. To use FlatBuffers, I suggest you write your custom logic in Go.

I try to use flatbuffers in Go after I know that gopher-lua only support pure Lua5.1. Like @mofirouz said, flatbuffers and protobuf need c bindings. Now I am refactoring our code to let flatbuffers work with our project.

Thanks @sean & @mofirouz for reply.

2 Likes