You need to change it like that in order to get what you want:
dolocal c = Object
c.__index = c
c.__new =function(...)local s1 ={}setmetatable(s1, c)local init =rawget(c, "init")iftype(init)=="function"then
init(s1, ...)endreturn s1
end
c.new =function(...)local s1 = c.__new(...)local postInit = s1.postInit
iftype(postInit)=="function"then
postInit(s1, ...)endreturn s1
endendlocal __Object = Object
MyClass =function(b,a)if a thenassert(type(a)=="function","Second argument to Core.class() should be a function or null")end
b = b or __Object
local c ={}
c.__index = c
setmetatable(c, b)
c.super = b
local v
c.__new =function(...)local b =getmetatable(c)local s1
if a then
s1 = b.__new(a(...))else
s1 = b.__new(...)endsetmetatable(s1, c)local init =rawget(c, "init")iftype(init)=="function"then
v = init(s1, ...)endreturn s1, v
end
c.new =function(...)local s1 = c.__new(...)local postInit = s1.postInit
iftype(postInit)=="function"then
v = postInit(s1, ...)endreturn s1,v
endreturn c
endlocal test = MyClass(Sprite)function test:init()local a =3123return a
endlocal instance, v = test.new()print(instance, v)
The question is. Why you cant just attach this variable to "self"?
Comments
https://github.com/gideros/gideros/blob/master/luabinding/property.lua
You need to change it like that in order to get what you want:
The question is. Why you cant just attach this variable to "self"?
Likes: oleg
I wanted to have access to obj and obj.body inside the init.
I can have access to those this way:
Likes: MoKaLux
very much appreciated