From: klaas.holwerda <kho...@xs...> - 2006-02-24 20:48:28
|
Hi John, After hours of searching around what i possibly do wrong i give up. It is the next peace of code in canlua.cpp It call the hit function in the script incircles.lua, and i tested that it does ( after loading it from the menu in the sample of course ). But somehow the boolean return result is totally wrong. I went as far as calling a lua function which adds two numbers, and return that number, and it has the same behaviour. Meaning that at least the first time the result is at number 9 on the returned stack?? It even tells there are 9 result, while i think there is only one. With lst.GetBooleanType(0) the application just stops, there is an error generated in the check for the boolean type, but where that error end up is not clear to me. Do you have any idea what i am doing wrong? It would be nice if the sample actually worked before the first release :-( Thanks for some help if you can find the time. Thanks also for the nice changes, i hope to once understand them all :-) Klaas bool wxlCanObjScript::DoIsHit( double x, double y, double absx, double absy ) { double xh,yh; xh = x - absx; yh = y - absy; // run all statements in the script which should be returning a hit on the object or not wxLuaState lst = *(m_canvas->GetLuastate()); lua_State* L = lst.GetLuaState(); lua_getglobal( L, wx2lua(m_objectname + wxT("Hit")) ); lst.lua_PushNumber( xh ); lst.lua_PushNumber( yh ); if ( lst.lua_PCall( 2, 1, 0 ) != 0 ) lst.SendErrorEvent( wxT("wrong hit function") ); int argCount = lua_gettop(L); bool hit = lst.GetBooleanType(9); //wxLogDebug( "hit %d", hit ); if (hit) return true; return false; } |