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)
Examples you can find in GitHub repository
Notes
This is extension, what we use in Family Age
If you will use our extension and find some bugs or have some suggestions, you are welcome, tell about it!
NE wrapped by @vergil12345678
@Insality
Great work. This extention can save great effort when using pb.
I had tried this extention today and it worked well in most cases. There is only one finding: cann’t decode protobuf type “any”. For details, you can take a look here:
I’m testing this as a way to minimise data with Nakama. It’s very efficient, about four times the size of json in my initial tests. It doesn’t seem to work in HTML5, which makes sense since it’s not listed as a supported platform.
Could this extension be made to work for HTML5, or is that crazy talk?
It turns out it IS possible! I’ve implemented the game logic in the game and want to optimise the messages from json. So I went back to see where the HTML5 build failed. And now it doesn’t, it just works! I must have configured it incorrectly last time in some way. Apologies for the previous post. Protobuf is go!
Yea, sure protobuf allow you use nested tables. In your example here is mismatch in protobuf structure and real data structure. You describe objects_hit_ttls as