lua-users home
lua-l archive

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


On Sep 29, 2008, at 3:26 PM, Juan Manuel Alvarez wrote:

Thanks for all the quick replies!

I could make it work using lua_pushvalue(-1), but I am still having
problems with parameters.
I am doing the operations in the following order:

luaL_loadbuffer

lua_pushvalue(-1)
lua_pcall // to load the global table

ADJUSTED:
lua_pushvalue(-1)
lua_getglobal
lua_pushnumber // parameter 1
lua_pushnumber // parameter 2

// lua_pushvalue(-1)
lua_pcall

The last pcall, gives me the error "attempt to call a number value".

The same sequence without the parameters works fine for me. Can you
please point me in the right direction?
For parameters, you need to make sure you do the push_value(-1) beforehand... otherwise your function itself becomes a parameter, throwing off the stack number.