Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/lua/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Lua 从表WIN'中检索的函数引用;我不接受任何论据_Lua - Fatal编程技术网

Lua 从表WIN'中检索的函数引用;我不接受任何论据

Lua 从表WIN'中检索的函数引用;我不接受任何论据,lua,Lua,我有一个函数引用表,如下所示: KLC.ChatCommandBank = { test = KLC.TestFunction, config = KLC.OpenInterfaceOptions, option = KLC.OpenInterfaceOptions, options = KLC.OpenInterfaceOptions, help = KLC.PrintHelp }; 但是当f=“test”和t是一个字符串表时,我调用 KLC.ChatCommandBank[f](t);

我有一个函数引用表,如下所示:

KLC.ChatCommandBank = {
test = KLC.TestFunction,
config = KLC.OpenInterfaceOptions,
option = KLC.OpenInterfaceOptions,
options = KLC.OpenInterfaceOptions,
help = KLC.PrintHelp
};
但是当
f=“test”
t
是一个字符串表时,我调用

KLC.ChatCommandBank[f](t);
然后是函数

function KLC:TestFunction(tab)
    print(tab);
end
尽管调用函数时,
t
不是
nil
,但是
tab
的值为
nil

我怀疑这是因为函数引用表没有定义参数;我无法用谷歌找到任何东西,我自己的修补也无法修复它!因为当您将函数定义为
KLC:TestFunction(tab)
时,它会得到一个隐式参数
self
,该参数引用调用它的表

当您将其称为
KLC.ChatCommandBank[f](t)
时,您需要显式地传递某些内容来代替该参数:

KLC.ChatCommandBank[f](KLC, t)
或者,您可以将定义更改为
本地函数KLC.TestFunction(tab)