• Advertisement

Archived

This topic is now archived and is closed to further replies.

Returning Values in LUA

This topic is 5023 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

I''m using LUA 5, and havent yet nailed this one down: LUA code calls C++ function C++ function executes & returns value (int) LUA code grabs the return Something like: lua_function() { handle = cplusplus_function_get_handle_to_animal("cow"); }; Ok, so what code do I have to add to my c++ function so that it returns the value back to the lua script? Thanks for any tips on this... Salsa cooked it, your eyes eat it!
[Hugo Ferreira][Positronic Dreams][Colibri 3D Engine][Entropy HL2 MOD][My DevDiary]
[Yann L.][Enginuity] [Penny Arcade] [MSDN][VS RoadMap][Humus][BSPs][UGP][NeHe]
"our stupidity allways comes back to bite us in the ass... in a white-shark sort of way..." - Prozak

Share this post


Link to post
Share on other sites
Advertisement
This should be in the scripting forum, but well:

C-Functions known to Lua always look like int Function( lua_State* L);

When you''re done with reading the parameters from the lua stack you just push the values on the stack and return the number of the parameters at the end of your function.

Something like:

lua_pushnumber( L, 17 );
lua_pushstring( L, "Hello World" );
return 2;

Share this post


Link to post
Share on other sites

  • Advertisement