Jump to content

Exposing C++ methods to lua


Rick
 Share

Recommended Posts

If we have the lua state in C++, then I would expect that I could then expose a C++ method to use in lua using:

 

static int KattSendMessage(lua_State* L)
{
char* _msg = (char*)lua_tostring(L, 1);
char* _extra = (char*)lua_tostring(L, 2);

return 1;
}

BP L = GetLuaState();

lua_register((lua_State*)L, "KattSendMessage", KattSendMessage);

 

But that doesn't seem to work. My function never seems to get called and I also notice that when I save a script in the script editor that comes with the editor it always complains about KattSendMessage() being a nil value. I can do this with normal lua and it works. What would be different?

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...