On 2/24/06, klaas.holwerda <[EMAIL PROTECTED]> wrote:
> 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.

Fixed, I think, I added a printf for testing (like your wxLogDebug)
and it shows 0 or 1 depending where the mouse is.

> 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.

It kills lua if running, calling lua_error, see wxLuaState::terror.
The pushed functions and callbacks continue to work however, but since
you're running code from C, I'm not sure what happens either.
lua_error does a long_jmp, but to where I dunno...

> It would be nice if the sample actually worked before the first release :-(

Agreed.

> 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);   don't need this?
>     bool hit = lst.GetBooleanType(-1);  want return value at top of stack
       lst.lua_Pop(1); // pop returned value from stack to balance it
>
>     //wxLogDebug( "hit %d", hit );
>
>     if (hit)
>         return true;
>     return false;
> }

see
http://www.lua.org/pil/25.2.html

I'm committing the changes now.

Regards,
    John Labenski


-------------------------------------------------------
This SF.Net email is sponsored by xPML, a groundbreaking scripting language
that extends applications into web and mobile media. Attend the live webcast
and join the prime developer group breaking into this new coding territory!
http://sel.as-us.falkag.net/sel?cmd=lnk&kid0944&bid$1720&dat1642
_______________________________________________
Wxlua-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/wxlua-users

Reply via email to