This time I have a scoring system almost working that might need a little correction.
I start by setting my variables:
#This is the score we begin with (at this time)
oldScore = 0
#basicly mean that we set the score to the score+the points earned
newScore = (int(oldScore+scoreToAdd))
So to see the score I made a text object that always changes to the newScore
score.text = str(newScore)
This also works properly.
Finaly I change the oldScore to = newScore (works fine)
everything work as expected until we get this part of the script to trigger again. Than the oldScore = 0 again !
To make it clearer is here the actual code part:
if letterA:
if pressA.positive:
newScore = (int(oldScore+scoreAdd))
score.text = str(newScore)
letterA.endObject()
oldScore = newScore
I think that this doesnt work as the script itself is triggered by ‘pressA’ (a keyboard sensor)
would it be better with a custom property??
Well I’m not really into programming or anything, but i think the problem is how you are setting your oldScore variable, if i understand correctly, the script will always run from top to bottom, so say you played a game and got a newScore, when you started the script again, it would just change it back to 0. You would have to make sure that you setting oldScore = 0 happens once on the game start.