lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]




On Sunday, August 3, 2014, Littlefield, Tyler <tyler@tysdomain.com> wrote:
Hello all:
I'm working on this project:
http://github.com/sorressean/aspen
and want to seriously revamp scripting. All of my game-objects are objects, so I'd like to wrap these in Lua and provide inheritance so that I just need to add methods and they can override etc. I have a few ideas and I'm hoping people can help with some solutions:
1) I'd love to have garbage collection actually free up the object.
2) Inheritance: I never deal with multiple inheritance, so that's not an issue.

I'm having a really hard time writing this, however. Are there any examples that show how to pull this off the right way? I'd ultimately be happy with two classes, one of which inherits the other so I can see how best to do that in the API.

I'd greatly appreciate any information/help. TIA,

--
Take care,
Ty
http://tds-solutions.net
He that will not reason is a bigot; he that cannot reason is a fool; he that dares not reason is a slave.
 

 Maintaining objects that live in both Lua and C / C++ is hard. At the API intersection, we've had more success by keeping the system language abstractions simple and dumb. We ended up doing extra work to unwind the fanciness from C++, only to remake the-same-but-different abstractions in Lua. 

If you can make your C binding feel more procedural-y and less object-y, then your Lua objects will be extremely simple to make. If you're like me, perhaps the biggest problem is over-doing the object features and the interface. Lua almost begs you to write your own object system and it's hard to know when to stop, until you've done it a few times.

Don't know if that helps. I imagine you're not going to re-write tons of C code. But consider just simplifying things at the binding/intersection between the two. 

-Andrew