Python problem::rpeats

Greetings:
I am having a python script problem, i use this code

import GameLogic as g
control=g.getCurrentController()
objeto=control.getOwner()
actores=control.getActuators()
sensores=control.getSensors()
aX=actores[0]
bX=sensores[0]
if bX.isPositive():
	random=(int) (g.getRandomFloat()*10)
	if random>7 | random==0:
		while random>7:
			random=(int)(g.getRandomFloat()*10)
	if random==1:
		aX.setObject("Box1")
	elif random==2:
		aX.setObject("Tri1")
	elif random==3:
		aX.setObject("LL1")
	elif random==4:
		aX.setObject("SR1")
	elif random==5:
		aX.setObject("LR1")
	elif random==6:
		aX.setObject("Linea1")
	else:
		aX.setObject("SL1")
g.addActiveActuator(aX,1)

to randomize the piece to add in a tetris like game, i have a Message sensor and a EditObject actuator, the message is send whenever a piece touches the floor, the problem is that it allways adds two pieces instead of one
Any ideas on how to fix this?
Edited::
Changed if bx: for if bx.isPositive()

I thinks that’s why the Sensor is shooting twice. A positive and a negative Pulse. (Most Sensors do that.) So You have to ask:

if bX.isPositive():
    ....

Hope that helps, Doc :smiley:

Greetings:
Thanks Doc, i tried that and it helped a little, before that it added two different pieces now it adds the same piece twice, any thoughts?

Hello!
Try that:

[...]
if bX.isPositive():
    [...]
    g.addActiveActuator(aX,1)
else:
    g.addActiveActuator(aX,0)

note: the two last lines are useless in the case of an AddObjectActuator(and can be removed) but could be usefull with a MotionActuator for example(I wrote them for your information).

Greetings:
Thanks MolFlesh, that fixed it :smiley: