[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: Ask userdata type from Lua
- From: Luiz Henrique de Figueiredo <lhf@...>
- Date: Sat, 1 Jul 2023 07:37:06 -0400
> Or should I best present a "tostring metafunction" for each of my
> userdata, which is programmed similar to f_tostring in liolib.c,
If you use luaL_setmetatable, then this is automatically done for you:
luaL_setmetatable sets __name to the string it gets. Then tostring
calls luaL_tolstring which uses __name to convert userdata to
tostring.