Rick Posted November 20, 2013 Share Posted November 20, 2013 Any ideas on how I can pass & store a lua table to a C++ method and then bring it up and call a function in that table (by name, which I'll also store) it at a later time using LE's lua implementation? The name of the table is not know as I'll be passing 'self' to the C++ method. I just don't know what the C++ parameter should be and how to find it and make the call. Words can't explain how much I hate working with the stack in lua Quote Link to comment Share on other sites More sharing options...
Admin Posted November 20, 2013 Share Posted November 20, 2013 The table is created in Lua? You need to set it to a global variable and then put it back on the stack with PushString("variablename"). If you look at the source for App.cpp it gets a table by variable name, then calls the Start function, which is a member of the App table. These are some pretty advanced topics. Usually I would expect data to flow the other way, from C++ to Lua. Quote Link to comment Share on other sites More sharing options...
Rick Posted November 20, 2013 Author Share Posted November 20, 2013 I can't really assign it to a global var. I'm setting up a callback system where I'm telling the C++ class the table function to be the callback. This will be done from within a lua class function. function ProfileMenu:Enter() self.Network:RegisterCallback(msgID, self, "Callback") end function ProfileMenu:Callback(reader) end I'm looking at code like the following but you don't expose some of these lua functions so I might have to bring in lua myself. What version of lua is being used in case I have to do this? http://lua-users.org/files/wiki_insecure/users/ArielManzur/tolua++/tolua_base.h As you can see lua_Object is a parameter type which is a table. You store some kind of reference from it and retrieve it later to call. Quote Link to comment Share on other sites More sharing options...
Rick Posted November 21, 2013 Author Share Posted November 21, 2013 I got this working. A lot of screwing around but I got it. I'll make a blog or tutorial on all that stuff I needed to do to get all this working. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
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.