Categories
- Blog (104)
- Lua (13)
- Miscellaneous (48)
- Photos (6)
- Programming (33)
- Python (15)
- Sample (3)
- Web Design (3)
- Writing (2)
- Portfolio (40)
- Snippets (28)
- Blog (104)
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 arguments, bytecode, dump, function, Lua
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…