【发布时间】:2017-01-15 02:43:35
【问题描述】:
我需要在 lua 中定义一些变量,这些变量在访问时会导致调用 C++ 函数:
Lua:
var rootname = root.name; // 'root' acts as a call to c++ function defined below
C++:
class Node
{
std::string name;
}
Node * root()
{
return MyNodeGraph->GetRoot();
}
在 Lua 中可以吗?
【问题讨论】:
-
是的。检查 lua api。
-
访问
root时,您正在访问索引root的_G表。你想要做的已经可以在 vanilla Lua 中实现了。
标签: function properties lua