Tag Archives: dump

Lua – Get number of parameters in a function

The following snippet defines a function num_args(func) that returns the number of parameters within a function as a string:

num_args(function(a,b,c) end) --> 3

It also works with functions that have variable arguments:

num_args(function(a,...)

Posted in Blog, Lua, Programming, Snippets | Tagged , , , , | Leave a comment

Serializing Lua objects into Lua Code

The following little snippet allows you to ‘pickle’ Lua objects directly into Lua code (with the exception of functions, which are serialized as raw bytecode). Metatable support is on the way, but for now, it should be useful enough.

Example

Posted in Blog, Lua, Programming, Snippets | Tagged , , , , , , | 1 Comment