lua-users home
lua-l archive

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


I'm new to lua. I'd like to do the following:
From lua, call a C function, with a lua function as one of the parameters, eg.

[ptr is pointer to a C++ object' instance, 10 is a future time in ms]

That C function will then put the function on a std::priority_queue<> to be called later. I'v read that the registry would help out here, the problem is what should I use as a unique key for that ?(because the function can be on the queue more than once,
I cant simply use the lua_topointer of the table)

What I would like to do is: Instead of placing the funcion on the registry, use (void*) var = lua_topointer(L,place where function is) and store that somewhere. The problem is, there isnt a lua_tofunction, so I cant put that back on the stack and call the function. This would have been nice because then I wouldnt need to access another table(registry) to find my function.[lots of misconceptions in that paragraph?]

The other alternative is to make a priority queue in lua and do all my stuff there, would you recommend doing this ? (Its just looping through and calling all the functions in it,
up to the current time, tho C performance would be nice)

I'm using lua 5.

Thanks !
Reyn Vlietstra.