Page 1 of 1

How to keep/check a score?

Posted: Sat Jan 20, 2018 12:14 am
by FairyKing
Apologies if this has been asked before, but if it has I can't find it.

So, what I'm trying to do is assign a score that starts at 0, goes up (and potentially down) depending on which choices the player makes, and then at certain points in the story what happens next depends on how the score compares to other numbers. My eventual goal is to have several such scores that get compared to each other to judge what the player is prioritizing. But I don't know the right code to make even a single score work.

What I have now is this before the start:
default score = 0

And this after the player makes a choice that will increase the score:
$ score += 1

And this when I want to check the score:
if score < 0:
"You scored some points!"
else:
"You didn't score any points!"


But when I playtest the game, it gives me the "You didn't score any points!" text even when I made the choice to increase the score. Can someone explain what I'm doing wrong? I know very little Python so please state your answer as simply as possible.

Re: How to keep/check a score?

Posted: Sat Jan 20, 2018 12:54 am
by Ana
You probably forgot the = sign after the <. This should fix it:

Code: Select all

    if score <= 0:
	"You scored some points!"
    else:
	"You didn't score any points!"
Also, I think you can just use this as the code for the beginning (after the label start), not sure how the default one works.

Code: Select all

    $ score = 0

Re: How to keep/check a score?

Posted: Sat Jan 20, 2018 1:09 am
by FairyKing
I tried choosing the option that didn't gain points, and it gave me the "You scored some points!" result. Only then did I realize I had mixed up < and >!
I feel foolish = True