lua-users home
lua-l archive

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


I have spent the past 6 hours trying to solve this ! and i coulnt get anywhere :s

I want to be able to create a lua table in a c++ file and then pass that to a lua script file, which has the following lua function:

function MTable (t)
local n=#t
    for i=1,n do

 i dynamically created a one dimensional array with two strings:


so now i have the table on top of the stack.
I  have verified it by writting this :if( lua_istable(L,lua_gettop(L))) which returned 1, which means it is a table.

then I did this:
lua_getglobal(L, "MTable");    // push the lua function onto the stack

uint32_t   result = lua_pcall(L, 1, 0, 0);  //argument 1 is for the table
 if (result) {
 printf(stderr, "Failed to run script: %s\n", lua_tostring(L, -1));

so I got that error:
Failed to run script: attempt to call a table value

Kindly note that the file has several other functions that i am calling successfully from c++.

can somebody please help me solve this error ? can this be a bug from LUA? cz i followed the steps very correctly...i guess !