Hi,
I’m new to Defold (Love it so far, as it offers a rigid structure that i lacked so far), trying to get a grasp of how to communicate with objects and access properties.
I’m having the following:
local newtile = factory.create("#tilesfactory", pos, nil, {}, 1) pprint(newtile) pprint(go.get(newtile, "passable"))
And this tilesfactory use the prototype tile.go which starts as following:
go.property("passable", true) function init(self) [...] end
When i build, i get the following:
First pprint: DEBUG:SCRIPT: hash: [/instance0]
Second: '(null)' does not have any property called 'passable'
Any idea to help me understand how to access properties and use the ids (newtile)?
Thanks in advance for your help,
K
Solution:
I needed to access the script component of the object, to get the property.
So the url to provide to the go.get need to append the “script” fragment.
local url = msg.url(newtile)
url.fragment = "script" -- or any id that you have set on it
pprint(go.get(url, "tiletype"))