Anyways, I'm designing a program[1] that defines basic components, such as Action, Item, and Container. For the purpose of this email, I will focus on the Container component, which has the sole purpose of containing items and applying arbitrary restrictions to its contents. Specifically, given a Container named Hand, the following restrictions would apply:
- contains cards of any type (club, diamond, spade, heart)
- may contain no more than 5 cards
- Is only view-able by the player (hidden from opponent's view)
What I'd like to do is define a generic class in C++ named Container[2] which could then be accessed and instantiated in lua as a table. It seems as though UserData or UserObject is what I need. However, In addition to not seeing any example code of how to use such a defined object without first instantiating it (eg, passing an instance to lua), I'd like to find a way to do so that doesn't tightly couple QtLua to the Container class, should I decide to revert to a different binding language (Such as QtScript). My first instinct is to employee multiple inheritance, but I can't help but think this is sloppy, and that there is a cleaner way to do this.
In short, my question is this:
- How do I wrap a class and pass it to lua, rather than wrapping an instance of that class to pass to lua?
--
Regards,
Edwin O Marshall (aspidites)