Script loop

Greetings:
I am having a really confusing problem with my tetris clone game, whenever a line is completed it dissapears as it is supposed to, but, when the next piece touches the floor my empty that adds the pieces enters in a loop, it keeps adding pieces, the weird thing is that if i set the randomizer script to allways add the same piece this problem disappears, any thoughts?

the code for the randomizer is this:


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() or sensores[2].isPositive():
	random=(int) (g.getRandomFloat()*10)
	if random>7 or random==0:
		while random>7:
			random=(int)(g.getRandomFloat()*10)

	if random==1:
		aX.setObject("Box")
	if random==2:
		aX.setObject("Tri")
	if random==3:
		aX.setObject("LI")
	if random==4:
		aX.setObject("SD")
	if random==5:
		aX.setObject("LD")
	if random==6:
		aX.setObject("Line")
	if random==7:
		aX.setObject("SI")
if bX.isPositive() or sensores[2].isPositive():
	g.addActiveActuator(aX,1)
else:
	g.addActiveActuator(aX,0)

I cant really tell unless I see you logic setup but:


if bX.isPositive() or sensores[2].isPositive():
   random=(int) (g.getRandomFloat()*10)
   if random>7 or random==0:
      while random>7:
            random=(int)(g.getRandomFloat()*10)

   if random==1:
      aX.setObject("Box")
   if random==2:
      aX.setObject("Tri")
   if random==3:
      aX.setObject("LI")
   if random==4:
      aX.setObject("SD")
   if random==5:
      aX.setObject("LD")
   if random==6:
      aX.setObject("Line")
   if random==7:
      aX.setObject("SI")
if bX.isPositive() or sensores[2].isPositive():
   g.addActiveActuator(aX,1)
else:
   g.addActiveActuator(aX,0) 

is the same as:


if bX.isPositive() or sensores[2].isPositive():
   random=(int) (g.getRandomFloat()*10)
   while random > 7  or random < 1:
	   random=(int)(g.getRandomFloat()*10)

   obj = {"1":"aX.setObject('Box')", "2":"aX.setObject('Tri')",
		"3":"aX.setObject('LI')","4":"aX.setObject('SD')",
		"5":"aX.setObject('LD')", "6":"aX.setObject('Line')",
		"7":"aX.setObject('SI')"}

   eval(obj[str(random)])
   g.addActiveActuator(aX,1)

else:
   g.addActiveActuator(aX,0) 

Greetings:
Thanks for the code, i am starting in python, abou the logic i`ll look for a free space to upload the file so you can see the setup, for now, it is triggered whenever it receive one of two messages, either “start”, for the first piece, or “add”, when it finish checking if there was a line