fix lua event bug

This commit is contained in:
Eduardo Bart 2011-11-13 02:49:32 -02:00
parent ce3b02fa09
commit 48c22756f5
1 changed files with 13 additions and 15 deletions

View File

@ -77,22 +77,20 @@ private:
template<typename... T> template<typename... T>
int LuaObject::callLuaField(const std::string& field, const T&... args) { int LuaObject::callLuaField(const std::string& field, const T&... args) {
if(m_fieldsTableRef != -1) { // note that the field must be retrieved from this object lua value
// note that the field must be retrieved from this object lua value // to force using the __index metamethod of it's metatable
// to force using the __index metamethod of it's metatable // so cannot use LuaObject::getField here
// so cannot use LuaObject::getField here // push field
// push field g_lua.pushObject(asLuaObject());
g_lua.pushObject(asLuaObject()); g_lua.getField(field);
g_lua.getField(field);
if(!g_lua.isNil()) { if(!g_lua.isNil()) {
// the first argument is always this object (self) // the first argument is always this object (self)
g_lua.insert(-2); g_lua.insert(-2);
g_lua.polymorphicPush(args...); g_lua.polymorphicPush(args...);
return g_lua.protectedCall(1 + sizeof...(args)); return g_lua.protectedCall(1 + sizeof...(args));
} else { } else {
g_lua.pop(2); g_lua.pop(2);
}
} }
return 0; return 0;
} }