[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: Re: calling a function who's name is stored in a lua table
- From: Klaus Ripke <paul-lua@...>
- Date: Tue, 12 Jan 2010 13:09:06 +0100
On Tue, Jan 12, 2010 at 10:56:27AM +0000, David Given wrote:
> On 12/01/10 10:50, sean farrow wrote:
> > essentially is there a way of finding a value in a table given it's
> > key?
sure, that's why it is called key.
You may want to reread http://www.lua.org/manual/5.1/manual.html#2.3
and http://www.lua.org/pil/11.1.html ff
> function callfunction(n, ...)
> local name = AtcActions(n)
I'd even say AtcActions[n]
> local f = _G[name]
> return f(...)
> print(callfunction("2", "word"))
I'd go so far as to try print(callfunction(2, "word"))
(there is no magic string-number-conversion for keys).