I tried setting an int in the child class and using it in the parent and that was fine, but I can’t get the same to work for a pointer. Here’s a simplified version of my code:
function Child:init()
self.super:init() -- calls Parent:init()
self.var = 2
self.MyDerivedClass = self
end
function Child:Test()
Msg( "in test" )
end
function Parent:init()
self.MyDerivedClass = nil
self.var = 1
end
function Parent:Function()
Msg( self.var ) -- prints 2, the child variable value, as expected
self.MyDerivedClass:Test() -- crashes. Why?
end
c = Child()
c:Function() -- call Parent:Function()
Any ideas what the problem is and more importantly, how I might fix it? All input is appreciated