[SOLVED] Factory object communication with its prototype!

Hello!
I’m new to Defold game development and I have a question.
How can a factory game object’s script communicate with the factory’s prototype script?
This image explains further what I mean

Thank you!

Well it depends on what you mean. I will explain the 2 cases.
If you mean that the gameobject should communicate to the beefactory component, that is only one single way to do it and that is factory.create("#beefactory, …, …)
No other communication can be to the factory component.

If you mean that you want to communicate with whatever comes OUT of the factory it is you can do this in your gameoobject script:

local new_object = factory.create("#beefactory", vmath.vector3(someposition))
msg.post( new_object, "a_message", { some = data } )

Make sure just to have some script on the bee object that handles the message you send to it.

2 Likes

The second case answers my question… Thanks a lot! :smile:

I first looked at the screenshot and thought it read beerfactory and immediately went “Mmm I’m gonna like this game”. A game about bees can also be fun I guess… :slight_smile:

2 Likes