int NodeWithLua::hook_goto() {
auto hook = "hook_goto";
luabridge::LuaRef table = luabridge::getGlobal(L, _tableName);
auto F = table[hook];
if (!F.isFunction()) {
// auto s = std::format("{} {} is not a function!", _functionName, hook);
// std::cerr << s << std::endl;
// throw std::runtime_error(s);
return 0;
}
auto over = F();
if (over.hasFailed()) {
std::cerr << over.errorMessage();
throw std::runtime_error(over.errorMessage());
}
if (over.size() > 0) {
auto gotoNodeId = over[0].cast<int>().valueOr(0);
return gotoNodeId;
}
return 0;
}