我在C#程序中加载了这个脚本
function test()
print ("A")
end
但是当我尝试调用它时
LuaFunction func = lua.GetFunction("test")
func.call()
我遇到func为空的问题。
我错了什么?
答案 0 :(得分:1)
您说您已将<{em> test
脚本加载到C#程序中。这还不够。您必须执行生成的块代码,以便分配全局test
变量。
始终提醒
function test()
print ("A")
end
只是一个语法糖:
test = function()
print ("A")
end
当Lua 加载某些代码时,它只是将源代码编译成字节码。符号化test = function() end
仅在运行时执行,而不是在编译时执行。