|
|
@@ -814,50 +814,65 @@ void PolycodePlayer::handleEvent(Event *event) {
|
|
|
case InputEvent::EVENT_KEYDOWN:
|
|
|
{
|
|
|
if(L && !crashed) {
|
|
|
+ lua_getfield (L, LUA_GLOBALSINDEX, "__customError");
|
|
|
+ errH = lua_gettop(L);
|
|
|
lua_getfield(L, LUA_GLOBALSINDEX, "onKeyDown");
|
|
|
lua_pushinteger(L, inputEvent->keyCode());
|
|
|
- lua_pcall(L, 1,0,errH);
|
|
|
+ lua_pcall(L, 1,0,errH);
|
|
|
+ lua_settop(L, 0);
|
|
|
}
|
|
|
}
|
|
|
break;
|
|
|
case InputEvent::EVENT_KEYUP:
|
|
|
{
|
|
|
if(L && !crashed) {
|
|
|
+ lua_getfield (L, LUA_GLOBALSINDEX, "__customError");
|
|
|
+ errH = lua_gettop(L);
|
|
|
lua_getfield(L, LUA_GLOBALSINDEX, "onKeyUp");
|
|
|
lua_pushinteger(L, inputEvent->keyCode());
|
|
|
- lua_pcall(L, 1,0,errH);
|
|
|
+ lua_pcall(L, 1,0,errH);
|
|
|
+ lua_settop(L, 0);
|
|
|
}
|
|
|
}
|
|
|
break;
|
|
|
case InputEvent::EVENT_MOUSEDOWN:
|
|
|
{
|
|
|
if(L && !crashed) {
|
|
|
+ lua_getfield (L, LUA_GLOBALSINDEX, "__customError");
|
|
|
+ errH = lua_gettop(L);
|
|
|
lua_getfield(L, LUA_GLOBALSINDEX, "onMouseDown");
|
|
|
lua_pushinteger(L, inputEvent->mouseButton);
|
|
|
lua_pushnumber(L, inputEvent->mousePosition.x);
|
|
|
- lua_pushnumber(L, inputEvent->mousePosition.y);
|
|
|
+ lua_pushnumber(L, inputEvent->mousePosition.y);
|
|
|
lua_pcall(L, 3,0,errH);
|
|
|
+ lua_settop(L, 0);
|
|
|
}
|
|
|
}
|
|
|
break;
|
|
|
case InputEvent::EVENT_MOUSEUP:
|
|
|
{
|
|
|
if(L && !crashed) {
|
|
|
+ lua_getfield (L, LUA_GLOBALSINDEX, "__customError");
|
|
|
+ errH = lua_gettop(L);
|
|
|
lua_getfield(L, LUA_GLOBALSINDEX, "onMouseUp");
|
|
|
lua_pushinteger(L, inputEvent->mouseButton);
|
|
|
lua_pushnumber(L, inputEvent->mousePosition.x);
|
|
|
- lua_pushnumber(L, inputEvent->mousePosition.y);
|
|
|
+ lua_pushnumber(L, inputEvent->mousePosition.y);
|
|
|
lua_pcall(L, 3,0,errH);
|
|
|
+ lua_settop(L, 0);
|
|
|
}
|
|
|
}
|
|
|
break;
|
|
|
case InputEvent::EVENT_MOUSEMOVE:
|
|
|
{
|
|
|
if(L && !crashed) {
|
|
|
+ lua_getfield (L, LUA_GLOBALSINDEX, "__customError");
|
|
|
+ errH = lua_gettop(L);
|
|
|
lua_getfield(L, LUA_GLOBALSINDEX, "onMouseMove");
|
|
|
lua_pushnumber(L, inputEvent->mousePosition.x);
|
|
|
- lua_pushnumber(L, inputEvent->mousePosition.y);
|
|
|
+ lua_pushnumber(L, inputEvent->mousePosition.y);
|
|
|
lua_pcall(L, 2,0,errH);
|
|
|
+ lua_settop(L, 0);
|
|
|
}
|
|
|
}
|
|
|
break;
|
|
|
@@ -868,6 +883,8 @@ void PolycodePlayer::handleEvent(Event *event) {
|
|
|
|
|
|
bool PolycodePlayer::Update() {
|
|
|
if(L) {
|
|
|
+ lua_getfield (L, LUA_GLOBALSINDEX, "__customError");
|
|
|
+ errH = lua_gettop(L);
|
|
|
if(doCodeInject) {
|
|
|
printf("INJECTING CODE:[%s]\n", injectCodeString.c_str());
|
|
|
doCodeInject = false;
|
|
|
@@ -880,6 +897,7 @@ bool PolycodePlayer::Update() {
|
|
|
lua_pushnumber(L, core->getElapsed());
|
|
|
lua_pcall(L, 1,0,errH);
|
|
|
}
|
|
|
+ lua_settop(L, 0);
|
|
|
}
|
|
|
return core->Update();
|
|
|
}
|