starwing / lua-protobuf

A Lua module to work with Google protobuf
MIT License
1.71k stars 388 forks source link

bad argument #1 to 'encode' (type 'Person' does not exists) #248

Open DJKarlHarris opened 1 year ago

DJKarlHarris commented 1 year ago

使用protoc模块载入没问题,但是直接用pb.load(...)去载入xxx.pb的话就找不到

DJKarlHarris commented 1 year ago

使用pb.loadfile成功了,但是为什么loadfile没有被作者挂出来呢

starwing commented 1 year ago

因为用这个库的很多人是在Unity里用的,他们不知道当前目录的概念,解释起来太麻烦,所以干脆在文档里删掉了所有文件相关的API,会用的人肯定知道怎么用。

你可以用io.open()读取你的.pb文件内容,然后用pb.load()载入

DJKarlHarris commented 1 year ago

谢谢作者!

DJKarlHarris commented 1 year ago

请问一下,在开发环境中,一般是将所有pb load进内存,还是用到一个load一个

starwing commented 1 year ago

最好当然是上来就load,然后就不动了

DJKarlHarris commented 1 year ago

好的!

DJKarlHarris commented 1 year ago

作者,请问有什么方案可以让多个lua文件,共享pb.so加载的协议吗? 在skynet中可以额外开多一个服务来存储这些协议,然后其他服务与其通信。

starwing commented 1 year ago

考虑一下pb.state(),unsafe里面有shared state的支持。