lua-users home
lua-l archive

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


Hello:
On 8/3/2014 6:36 PM, Gary V. Vaughan wrote:
On Aug 3, 2014, at 10:12 PM, 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,
A few implementations of class based OO:

http://lua-users.org/wiki/InheritanceTutorial

For a prototype based object system (See LDocs at top of file):

https://github.com/lua-stdlib/lua-stdlib/blob/master/lib/std/object.lua

Or simple table object cloning:

https://github.com/lua-stdlib/lua-stdlib/blob/master/lib/std/table.lua#L79

Hello:
I've followed the lua OO tutorials and have kind of gotten it working. My issues seem to come in when trying to translate this to c, however. I'm not sure why it's such a hard problem for me. I'm mainly looking for examples of how to do this in c-side API, as there are tons of lua OO ideas floating around out there.

 HTH,



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