[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: calling a function who's name is stored in a lua table
- From: Nevin Flanagan <Alestane@...>
- Date: Tue, 12 Jan 2010 08:21:32 -0500
> All globals, including functions, are (usually) stored in a special
> table called _G. So all you need to do is:
>
> function callfunction(n, ...)
> local name = AtcActions(n)
> local f = _G[name]
> return f(...)
> end
>
> e.g.:
> print(callfunction("2", "word"))
It's also perfectly functional to write
_G[AtcActions(n)](...)
(although not always easy to read).