Re: Opps...need help on how to manage c++ objects from Lua
So, I started to try to answer my own question. I wrote the following code as a test case. Some things are a bit sloppy, just test code.
I have an abstract class and then derive classes. I also have a class, FooManager that will hold those classes. The Foo class has a function "Awake" that it calls in the Lua script. Inside the script I want to grab the appropriate component and call its methods.
I've used the luabind::globals to give the FooManager class to the script. When I try to call the "sayName" method of Foo class I'm getting an error message, "No matching overload found, candidates: void sayName(Foo&)"
I needed to first bind my abstract class "IFoo." And, in my class Foo I needed to bind the constructor with the derived IFoo. So now, all works. I will post the working code below in case anyone else needs to know how to do.
All the samples online seem to show how to bind C++ to Lua and then construct the objects from Lua. However, if you wish to do "declarative" programming, creating and managing the objects on the C++ side and then allowing Lua to manipulate those objects, I hadn't found any clear samples. So, here's a sample...