add object with script in it.

Hi,
My question is this: if I have object with script in it…and I add it to the scene while the game is runnig, and then I add the same object again…what happens…the script multiplies two times and executes two times at a frame or is it just the program knows that this is the same script and executes it one time only?

two times. The same script can do diferent things for each object what is working for. So it can’t be ejecuted only one time for all the objets.

I THINK… I’m not a guru.

10x, but I’m still confused wich is right-> to have script in added object or to have same script wich handles added objects somewhere else.
And one more thing I need to ask.
What is this lights, do they work while GE is runnig fullscreen with blenderplayer or are they only for in-blender use. And how they work, what they changes?
http://bogdana2005-bg.com/temp/lights.jpg

You have to decide how the game goes, and where the script belongs. Is the script only for the add object? then I would put it there.

Is the script for several different objects/actions etc? then put it with what ever function calls it.
Draw it on paper.

The way to test for this is:

  • Enable the “Show Framerate and Profile” option in the game menu.
  • Run game with one object - watch the logic load percentage
  • Run game with two objects - watch the logic load percentage
  • Note the differencesThat said; logic would dictate that each script is run independently for each object - even if all objects are running identical scripts.

As fisicomolon said: “The same script can do different things for each object”

PS: Another interesting test you might want to try: Is having each object running it’s own copy of the script in question more expensive than having a single script running for each object in the scene?

Give it a try.