lua-users home
lua-l archive

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

Okay, getting closer...

Following  page 123...

Okay... I have AWindowClass defined in script. I set a field within that table to be another table object with a metatable I've defined in C. I 've __index AWindowClass. AWindowClass has a .new method which takes a table and set's that objects metatable to that of AWindowClass.

So now{fields and stuff} ... When 0.FunctionInProtoTypeTable() is called, it won't find it in AWindowClass and look in the prototype's table. which it finds...Problem is, the initial 'self' state isn't be passed get's done when you reference a method with anObject:AFunction();

----- Original Message ----- From: "Kenk" <>
To: "Lua list" <>
Sent: Friday, October 23, 2009 12:49 PM
Subject: Re: Metatables, C and Script...

Hmm.. I see... I think page 123 accomplishes what I'm looking to do. let me play with that...


----- Original Message ----- From: "Luiz Henrique de Figueiredo" <>
To: "Lua list" <>
Sent: Friday, October 23, 2009 11:40 AM
Subject: Re: Metatables, C and Script...

Or once you define a metatable for an object, you can't extend it at all?

A metatable is just a plain ordinary table. You can do anything to it.
OTOH, you may choose to protect it from Lua code by adding __metatable=false
to it.