Logic Running 2x

I’m having an issue:

I have logic running with bricks and python.

I have a simple math operation where:

Item[‘prop1’] -= (AppleObject[‘prop2’] - OrangeObject[‘prop3’]) / 2

Prop1 = 40
prop2 = 13
prop3 = 2

Resulting Prop1 = 29

In other words, subtraction is taking place 2x. I’ve fiddled with the numbers enough and that’s exactly what’s happening. So that if I want the real number I have to divide by 4.

How do I stop the operation from taking place 2x.

I have it set up so when I press a Keyboard logic brick input, it will run a python script. Somewhere along the line something is being run twice.

I suggest to add some print statements that you see the results and how often it runs.

Beside that have a look in Double execution of a python controller

thanks for the link!

I don’t know much about Python. So my solution was just to force the logic brick to change states then change right back. In this way it only executes once.

I had already tried the pulse modes and tick rates and tap etc before I’d posted, but then after I read your response I thought about changing the states.

FOr sensors: Sensors - A Word on Pulses