[英]Crash when calling luabind function on object
When I try to run the "Run" function (defined in lua) from C++ (through luabind), I get the following error: 当我尝试从C ++(通过luabind)运行“运行”功能(在lua中定义)时,出现以下错误:
Unhandled exception at at 0x767BC41F in Game_Launcher.exe: Microsoft C++ exception: luabind::error at memory location 0x001BF8B8.
Game_Launcher.exe中0x767BC41F处的未处理异常:Microsoft C ++异常:内存位置0x001BF8B8处luabind :: error。
Using some try/catch trickery I got the slightly less useless messages of: 使用一些try / catch技巧,我得到了一些没用的消息:
Expression: lua runtime error
表达式:lua运行时错误
Expression: Run
表达式:运行
local function Run(self)
self.ticks = self.ticks + 1
end
return {
ticks = 0,
Run = Run,
}
void ScriptComponent::Initialize()
{
// I pipe everything through a filesystem, so the script must be loaded as a string first
String fileData;
fileSystem->LoadFromFile("myscript.lua", filedata);
int err = lual_loadstring(L, fileData);
luabind::object compiledScript(luabind::from_stack(L, -1));
lua_pop(luaState, 1);
luabind::object luaDataTable = compiledScript();
lua_pop(luaState, 1);
// Execute the run function
luaDataTable["Run"](luaDataTable);
}
Best I can tell, the luaDataTable
is a table and is valid. luaDataTable
我所知, luaDataTable
是一个表并且有效。 Not sure what I did wrong! 不知道我做错了什么!
如果我删除了它起作用的第一个弹出状态,我会出现,哎呀!
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.