lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]



Le ven. 23 avr. 2021 à 12:27, Robert Burke <sharpobject@gmail.com> a écrit :
>
> On Fri, Apr 23, 2021 at 7:10 PM 孙世龙 sunshilong <sunshilong369@gmail.com> wrote:
> > How to exchange the values of a specific variable (e.g: maybe a table)
> > between Lua_States? Is there a reliable library could achieve this?
>
> If it is a table, you need to serialize it, send over the encoded
> string, and deserialize it on the receiving end. If it is a table that
> refers to state that you don't want to serialize, such as uses of
> metatables to build classes, then you need a scheme for encoding which
> metatable it was on the sending end and resolving that encoded
> metatable reference to the corresponding metatable on the receiving
> end.
>
> I don't know of any library that attempts to solve even most of this
> problem, but for example love2d's thread module includes the encoding
> and decoding of (presumably acyclic) tables that contain only
> booleans, strings, numbers, love2d's userdata, and tables that also
> meet these constraints.

Pluto is one such library (and its rewrite Eris), and it goes pretty far. I never used it tought.

https://github.com/hoelzro/pluto
https://github.com/fnuecke/eris