diff --git a/.todo b/.todo index 34f09ef..e53b7f5 100644 --- a/.todo +++ b/.todo @@ -1,2 +1,2 @@ -add 3d-picking routines using temporary ODE ray geometries +add API documentation for ag.pickObjects() add audio capabilities diff --git a/ag.cc b/ag.cc index 39013fc..a6a57ba 100644 --- a/ag.cc +++ b/ag.cc @@ -100,8 +100,8 @@ namespace ag lua_getfield(L, -1, "_objects"); /* pushes 1 */ lua_pushinteger(L, *it); /* pushes 1 */ lua_gettable(L, -2); /* replace top */ + lua_remove(L, -3); /* remove 1 */ lua_remove(L, -2); /* remove 1 */ - lua_remove(L, -1); /* remove 1 */ if (!lua_isnil(L, -1)) { lua_pushinteger(L, next_index++); /* push key */ @@ -300,7 +300,7 @@ namespace ag lua_getfield(L, LUA_GLOBALSINDEX, "ag"); /* pushes 1 */ lua_getfield(L, -1, "_objects"); /* pushes 1 */ lua_pushinteger(L, id); /* pushes 1 */ - lua_pushvalue(L, 1); /* pushes 1 */ + lua_pushvalue(L, -4); /* pushes 1 */ lua_settable(L, -3); /* pops 2 */ lua_pop(L, 2); /* pops 2 */ } diff --git a/tests/managed_objects.lua b/tests/managed_objects.lua index 7450479..cee29d8 100644 --- a/tests/managed_objects.lua +++ b/tests/managed_objects.lua @@ -60,6 +60,11 @@ end function mousebutton_down_event(button, x, y) if (button == 1) then - ag.pickObjects(x, y) + objects = ag.pickObjects(x, y) + if (objects ~= nil) then + for id, obj in ipairs(objects) do + obj:setColor(0, 0, 1) + end + end end end