Posted 18 May 2014 - 05:21 PM
Hello, PROs!
I have an Object Oriented API which defines some GUI elements.
I ran into a problem with inheritance of objects that have tables inside themselves.
My code is based on http://www.lua.org/pil/16.2.html with a custom new() function:
However, I noticed that when creating a new instance of my class that looks like
It looks like it cannot be inherited from the parent class until I add sth like
Thanks for any reply!
Sincerely, viluon
I have an Object Oriented API which defines some GUI elements.
I ran into a problem with inheritance of objects that have tables inside themselves.
My code is based on http://www.lua.org/pil/16.2.html with a custom new() function:
New=function(this,...)
object = {}
setmetatable(object,this)
this.__index=this
return object
end,
(it works, hope it's "grammatically" okay)However, I noticed that when creating a new instance of my class that looks like
myObject={
position={
x=1,y=1,
},
}
(plus the new() function) the final object's (local test=myObject:new()) position.x is not accessible.It looks like it cannot be inherited from the parent class until I add sth like
test.position={}
test.position.x=6
--#OR
test.position={x=6,...}
Is there any solution for this problem? Defining position again and again ruins up the thought of OOP…Thanks for any reply!
Sincerely, viluon
Edited on 18 May 2014 - 03:23 PM