I am using inspect.lua to inspect table to string.
But, if the value is a userdata, it returns just <userdata 1>
I really need to know what the userdata type is, what the userdata value is, it's very important for debuging, I don't want do it in any IDE, I just want something can help me debug by print staffs.
A userdata value is a pointer to a block of raw memory. There are two kinds of userdata: full userdata, where the block of memory is managed by Lua, and light userdata, where the block of memory is managed by the host. Userdata has no predefined operations in Lua, except assignment and identity test.
# is the lua length operator which works on strings or on table arrays.
You cannot.
From the manual :
The type userdata is provided to allow arbitrary C data to be stored in Lua variables. A userdata value is a pointer to a block of raw memory. [...] Userdata has no predefined operations in Lua, except assignment and identity test.
As indicated by @Eric, the only thing you can do from Lua is inspect the metatable :
print(inspect(getmetatable(someuserdata)))
If you are using the C API, you should be able to register a custom function that prints whatever is held by the block.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With