Factory prototype script parameter namespace

When using a GO as a factory prototype each instance created runs the same attached script file and shares the parameters.
An exception to this appears to be if a table is created in init() (self.mytab = {})
I am think of using this to distinguish parameters between instances; is this typically what is done for this?
(Another option is to use msg.url() as a table key).
Are there other ways of dealing with this?
Currently I have a problem where a collision with one GO instance is triggering another GO instance.
I guess I could also try having a separate controller script and post to it.
I am looking for the neatest option:-)
Thanks.

You can read more about the local/global/script scopes here:

Thanks for the link, useful reading. Is there anything on the workings of how factory created GO’s share the same script file? e.g. one GO might be in update(), while the other is in on_message() changing values and effecting each other.

You don’t need to worry about race-conditions, if that’s what you’re implying.

In terms of sequencing, you can expect that in each frame, first the on_input will be called in all scripts, then the update for all scripts, and then the on_message for all scripts. So you can’t have one script processing a message while the other script is still in update. See here.

each instance created runs the same attached script file and shares the parameters.

That’s not true. Everything you store on self will be unique to the object, and other instances won’t have direct access to it.

4 Likes

OK thanks, I am misinterpreting what I am seeing:-)