Jump to content
  • Advertisement
Sign in to follow this  

Problems with lua_call

This topic is 4873 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

hi, I am using lua_call in my app and I can't seem to get it to work. It keeps quiting the program right after the call. I'm using references. I use a lua funtion to register a reference of a lua function into the host (c/C++), then later I use these lines to try to call that function.
[Lua Function]
function SomeFunction( n )
  return n

[C Code]
lua_rawgeti( L, LUA_REGISTRYINDEX, ref );
lua_pushnumber( L, param1 );
lua_call( L, 1, 1 );

so, I know that ref is a number, but the call just exits the program. I try to use pcall with 0 as a last parameter and that doesn't exit the program, but does not run the function either. I'm so comfused. Can anyone help? I'm using Lua 5.0 with MSVC++ 6.0 Denny.

Share this post

Link to post
Share on other sites
Guest Anonymous Poster
What does ref equal? Unless you are also registering your function in the registry independently, you need to retrieve it from LUA_GLOBALSINDEX not LUA_REGISTRYINDEX.

Share this post

Link to post
Share on other sites
After more debuging:
ok here's what I;ve found out. if I call a Lua function from my C program and that function (Lua) calls a C function that is not registered, no errors will be generated. Strange. Has anyone experienced this?

I just found lua_pcall and am using the return of this to pring my errors.

Sorry for the topic, and tanks alot for your help.


[Edited by - brain21 on February 15, 2005 9:06:53 PM]

Share this post

Link to post
Share on other sites
Sign in to follow this  

  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!