How to keep/check a score?

Discuss how to use the Ren'Py engine to create visual novels and story-based games. New releases are announced in this section.
Forum rules
This is the right place for Ren'Py help. Please ask one question per thread, use a descriptive subject like 'NotFound error in option.rpy' , and include all the relevant information - especially any relevant code and traceback messages. Use the code tag to format scripts.
Post Reply
Message
Author
FairyKing
Newbie
Posts: 5
Joined: Tue Jan 09, 2018 12:25 am
Deviantart: gusindor
Contact:

How to keep/check a score?

#1 Post 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.

Ana
Regular
Posts: 61
Joined: Sun Oct 12, 2014 5:56 pm
Contact:

Re: How to keep/check a score?

#2 Post 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

FairyKing
Newbie
Posts: 5
Joined: Tue Jan 09, 2018 12:25 am
Deviantart: gusindor
Contact:

Re: How to keep/check a score?

#3 Post 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

Post Reply

Who is online

Users browsing this forum: piinkpuddiin