Hello,
I’m trying and getting the component of a game object , created with a factory.
I can get it, but i’m not sure it’s the optimal way.
I think i must use this function: msg.url(socket, path, fragment)
So at first, for getting socket
and path
for the game object, i do this:
print(msg.url(go_id_returned_by_factory_create))
And it gives me someting like default:/instance0
, for the first instancied game object.
As the number is incremented, it’s easy to compute the instance number, with a table of instancied game objects.
Then i do this, for example
-- i is the index in my instancied game objects table.
local url_sprite = msg.url("default","/instance"..i-1, "sprite_component")
pos.x = pos.x + go.get(url_sprite, "size.x")
It works, but i wonder if there is a better way to get the url of a component.
Thank you for reading