Lua 调用字符串中的嵌套函数

如何从字符串中调用嵌套函数?

function first()
    function nested() print('function: nested') end
    print('function: first')
end

_G["first"]() --从字符串中调用 first 函数
点赞
用户9383219
用户9383219

nested是一个全局变量,所以您可以使用nested()_G.nested()_G ["nested"]()调用它。

2018-10-17 20:01:25