If you follow the code through logically step by step, you will see what the problem is.
Let's look at your code line by line (I'm adding numbers so that we can talk line by line...but these numbers shouldn't be in the actual code).
Code: Select all
1) label start:
2) $ point = 0
3) $ cor = none
4) scene bg sala de prova
5) if point > 0 and point <=10:
6) $ cor = "white"
7) elif point > 10 and point <=20:
8) $ cor = "green"
9) elif point > 20 and point <=30:
10) $ cor = "blue"
11) $ point += 15
12) "The color is [cor]"
Line 1 the game starts.
Line 2 you assign point to 0.
Line 3 you assign cor to none.
As Zestsubou notes that should be "None" or None.
But I would also recommend using current best practices and assigning those values using default. So like so:
Code: Select all
1) default point = 0
2) default cor = "None"
3) label start:
4) scene bg sala de prova
5) if point > 0 and point <=10:
6) $ cor = "white"
7) elif point > 10 and point <=20:
8) $ cor = "green"
9) elif point > 20 and point <=30:
10) $ cor = "blue"
11) $ point += 15
12) "The color is [cor]"
Okay moving on.
Line 4 you set the scene.
Line 5-10 you check to see what value point is. Let's do the check.
Line 5, is point greater than 0 and less than or equal to 10? No, because it is 0. Line 6 doesn't happen.
Line 7, is point greater than 10 and less than or equal to 20? No, because it is 0. Line 8 doesn't happen.
Line 9, is point greater than 20 and less than or equal to 30? No, because it is 0. Line 10 doesn't happen.
So after this section, cor is still "None" and point is still 0.
Line 11, you add 15 to point, so point is now 15 and cor is still "None"--because you haven't done anything to cor.
Line 12, since cor is still "None", this line will print: "The color is None."
Do you see the error now? You assign a color to cor before you add points to point. After you add points to point, you don't do your if/else check again.
Depending on exactly what you are doing (screens are a bit different), you need to check the points and assign color each time before you need to print the color. This can be made easier by making a method...which is a block of code you plan on repeating quite often.
Observe this version of the code:
Code: Select all
default point = 0
default cor = "None"
init python:
def colorCheck():
global point
global cor
if point > 0 and point <=10:
cor = "white"
elif point > 10 and point <=20:
cor = "green"
elif point > 20 and point <=30:
cor = "blue"
label start:
scene bg sala de prova
$ colorCheck()
"The color is [cor], it should be None."
$ point += 5
$ colorCheck()
"The color is [cor], it should be white."
$ point += 10
$ colorCheck()
"The color is [cor], it should be green."
$ point += 10
$ colorCheck()
"The color is [cor], it should be blue."
Now, if you are doing screens it is different. But I hope you can see the what was wrong with your original code.