lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]




Vegetable wrote:
> 
> 1) Sometimes calling my C-function from my lua script, the arguments given
> in my script are 'lost' : i call tex_draw(1,2,3,4) and i receive in my C-
> function (1,None,3,4).
> 

I add some info :

the C-function is :
static int tex_draw (lua_State *L)
{
    int n = lua_gettop(L);    /* number of arguments */
    if (n!=4)
    {
        writeStack(L);
        lua_pushstring(L, "mauvais nombre d'arguments passés à 'tex_draw'");
        lua_error(L);
    }
    for (int i=1;i<=4;i++)
        if (!lua_isnumber(L, i))
        {
            writeStack(L);/* does not affect the stack*/
            lua_pushstring(L, "argument non numérique donné à 'tex_draw'");
            lua_error(L);
        }
    static_cast<Texture*>(fl->GetData(
        lua_tointeger(L,1),TYPE_TEXTURE))
                        ->GetImg()->
                            Draw(lua_tointeger(L,2),
                                lua_tointeger(L,3),
                                lua_tonumber(L,4));
    return 0;
}


The error come in 

function draw_map()
        for i=0,map_size_x-1 do
                for j=0,map_size_y-1 do
                      tex_draw(abs(map[i][j]),(i-x_map)*32,(j-y_map)*32,1)
                end
        end
end

I have organized my program to show pages, and it draws the map only in page
0.

When i change the page and i come back to the page 0 there is the error.
Adding a print(".") instruction before the tex_draw(...) solves the
problem..... 






-- 
View this message in context: http://www.nabble.com/A-newbie-has-problems-with-Lua-tf2102860.html#a5795533
Sent from the Lua - General forum at Nabble.com.