A "point" system

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
VenatorUnum
Newbie
Posts: 8
Joined: Sat Jan 14, 2012 11:34 am
Contact:

A "point" system

#1 Post by VenatorUnum » Sat Jan 14, 2012 11:44 am

I noticed the "if" statement being able to be used with a certain point system.
The code can make it so you get different endings depending on what your score is ex:
if points >= 10:

e "Congratulations! You're getting the best ending!"

elif points >= 5:

e "It's the good ending for you."

else:

e "Sorry, you're about to get the bad ending."

I'm wondering as to how this works, every attempt I've made so far at adding this sort of system resulted in a bunch of errors.

I've recently played the VN Katawa Shoujo where a similar system was deployed, you'd get points with a certain character for your choices and then new options would open up later.

Can anyone explain to me how this works, and what codes to use?
Thanks in advance!

User avatar
DragoonHP
Miko-Class Veteran
Posts: 758
Joined: Tue Jun 22, 2010 12:54 am
Completed: Christmas
IRC Nick: DragoonHP
Location: Zion Island, Solario
Contact:

Re: A "point" system

#2 Post by DragoonHP » Sat Jan 14, 2012 12:03 pm

Maybe you have forgot to indent it properly.

Code: Select all

if points >= 10:
    e "Congratulations! You're getting the best ending!"
elif points >= 5:
    e "It's the good ending for you."
else:
    e "Sorry, you're about to get the bad ending."

VenatorUnum
Newbie
Posts: 8
Joined: Sat Jan 14, 2012 11:34 am
Contact:

Re: A "point" system

#3 Post by VenatorUnum » Sat Jan 14, 2012 12:16 pm

[quote="DragoonHP"]Maybe you have forgot to indent it properly.
quote]
No I did that fine in the script itself, just had no idea how to do it here as it's my first forum post ^^

User avatar
DragoonHP
Miko-Class Veteran
Posts: 758
Joined: Tue Jun 22, 2010 12:54 am
Completed: Christmas
IRC Nick: DragoonHP
Location: Zion Island, Solario
Contact:

Re: A "point" system

#4 Post by DragoonHP » Sat Jan 14, 2012 12:25 pm

Use the code tag to post code.

And can you post a snippet of your code...

User avatar
leon
Miko-Class Veteran
Posts: 554
Joined: Sun Oct 09, 2011 11:15 pm
Completed: Visual Novel Tycoon, Night at the Hospital, Time Labyrinth, The Buried Moon, Left of Center, Super Otome Quest
Projects: Lemon Project, Porcelain Heart, Dream's Dénouement
Organization: Team ANARKY
Contact:

Re: A "point" system

#5 Post by leon » Sat Jan 14, 2012 1:10 pm

The code looks fine. Maybe you forgot to declare variable points or character e? What errors are you getting?

VenatorUnum
Newbie
Posts: 8
Joined: Sat Jan 14, 2012 11:34 am
Contact:

Re: A "point" system

#6 Post by VenatorUnum » Sun Jan 15, 2012 4:32 am

Code: Select all

I'm sorry, but an uncaught exception occurred.

While running game code:
  File "game/script.rpy", line 75, in script
                 $ score += 5
  File "game/script.rpy", line 75, in python
                 $ score += 5
NameError: name 'score' is not defined

-- Full Traceback ------------------------------------------------------------

Full traceback:
  File "C:\Users\\Documents\RenPy Projects\renpy-6.13.7\renpy\execution.py", line 261, in run
  File "C:\Users\\Documents\RenPy Projects\renpy-6.13.7\renpy\ast.py", line 630, in execute
  File "C:\Users\\Documents\RenPy Projects\renpy-6.13.7\renpy\python.py", line 978, in py_exec_bytecode
  File "game/script.rpy", line 75, in <module>
NameError: name 'score' is not defined

Windows-post2008Server-6.1.7601-SP1
Ren'Py 6.13.7.1646
A Ren'Py Game 0.0
This is the error I currently get when I try to distribute points. I've tried declaring the actual characters, but then I get the following error:
I'm sorry, but an uncaught exception occurred.

Code: Select all

While running game code:
  File "game/script.rpy", line 75, in script
                 $ n += 5
  File "game/script.rpy", line 75, in python
                 $ n += 5
TypeError: unsupported operand type(s) for +=: 'ADVCharacter' and 'int'

-- Full Traceback ------------------------------------------------------------

Full traceback:
  File "C:\Users\\Documents\Projects\renpy-6.13.7\renpy\execution.py", line 261, in run
  File "C:\Users\\Documents\RenPy Projects\renpy-6.13.7\renpy\ast.py", line 630, in execute
  File "C:\Users\\Documents\RenPy Projects\renpy-6.13.7\renpy\python.py", line 978, in py_exec_bytecode
  File "game/script.rpy", line 75, in <module>
TypeError: unsupported operand type(s) for +=: 'ADVCharacter' and 'int'

Windows-post2008Server-6.1.7601-SP1
Ren'Py 6.13.7.1646
A Ren'Py Game 0.0
Removing the "=" sign didn't work there as I thought it would. No clue what's going wrong.
Last edited by VenatorUnum on Thu Sep 16, 2021 12:45 pm, edited 1 time in total.

User avatar
DragoonHP
Miko-Class Veteran
Posts: 758
Joined: Tue Jun 22, 2010 12:54 am
Completed: Christmas
IRC Nick: DragoonHP
Location: Zion Island, Solario
Contact:

Re: A "point" system

#7 Post by DragoonHP » Sun Jan 15, 2012 5:03 am

Try this...

Code: Select all

label start:
    $ start = 0

VenatorUnum
Newbie
Posts: 8
Joined: Sat Jan 14, 2012 11:34 am
Contact:

Re: A "point" system

#8 Post by VenatorUnum » Sun Jan 15, 2012 7:28 am

DragoonHP wrote:Try this...

Code: Select all

label start:
    $ start = 0
Thanks, that worked for a single point system but now the issue is that I'd like to assign points to invidual characters.
For instance I have person A, B and C

You get a menu with three options, option 1 gives a point for person A, option 2 for B, etc..
Depending on the amount of points you have your story progresses with either A B or C depending on the amount of points you have with each character.

Any way to do this?

User avatar
DragoonHP
Miko-Class Veteran
Posts: 758
Joined: Tue Jun 22, 2010 12:54 am
Completed: Christmas
IRC Nick: DragoonHP
Location: Zion Island, Solario
Contact:

Re: A "point" system

#9 Post by DragoonHP » Sun Jan 15, 2012 7:31 am

Code: Select all

menu:
    "This is option 1" if gg == 1:
        "hh"
    "This is option 2" if gg == 2:
        "hh"
and so on...

Or were you asking for something else...

User avatar
Arcanum
Veteran
Posts: 229
Joined: Mon May 09, 2011 9:07 am
Contact:

Re: A "point" system

#10 Post by Arcanum » Sun Jan 15, 2012 8:13 am

Do you want to make it so that, for example, not only you have to have, say, 10 points in A, but also more points in A than in B and C for you go to A path?

http://www.renpy.org/wiki/renpy/doc/tut ... er_Choices - This article is really helpful in that case.

VenatorUnum
Newbie
Posts: 8
Joined: Sat Jan 14, 2012 11:34 am
Contact:

Re: A "point" system

#11 Post by VenatorUnum » Sun Jan 15, 2012 8:23 am

Arcanum wrote:Do you want to make it so that, for example, not only you have to have, say, 10 points in A, but also more points in A than in B and C for you go to A path?

http://www.renpy.org/wiki/renpy/doc/tut ... er_Choices - This article is really helpful in that case.
Yes that's exactly what I needed, thank you! :D

Post Reply

Who is online

Users browsing this forum: Google [Bot]