Jump to content

Exposing Lua functions in C++ code


xtreampb
 Share

Recommended Posts

I want to create a lua script but expose the functions of this script to my C++ game. I am making the UI in lua and want to do something like this

KeyHit(KEY_P)
{
//do lua function calls
//int result=luaUIBtnPress();
}

 

I would also like to send what button was pressed in my lua UI back to my C++ function, as shown above. Can anyone guide me on how i can do this or a better way to do this. Or should I just use wxWidgets or another UI library?

 

Thanks

 

~Xtreampb~

bool Life()
{
 while(death=false)
 {
   if(death==true)
   return death;
 }
}

 

I have found the secret to infinite life

 

Did I help you out? Like my post!

Link to comment
Share on other sites

  • 2 weeks later...

I simply added LuaJit to the build so I could make calls to pop and push values off and onto the stack and effectively move data between Lua and my framework. As Josh doesn't expose any of those functions I had no choice but do that.

 

Using a binding library like tolua++ or LuaBind will give you a real access to your C++ classes if that's what you really need.

Intel Core i5 2.66 GHz, Asus P7P55D, 8Gb DDR3 RAM, GTX460 1Gb DDR5, Windows 7 (x64), LE Editor, GMax, 3DWS, UU3D Pro, Texture Maker Pro, Shader Map Pro. Development language: C/C++

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

×
×
  • Create New...