Setting up endings for a Dating Sim based on points

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.
Message
Author
Plusle
Newbie
Posts: 18
Joined: Sat Feb 08, 2014 6:50 am
Contact:

Setting up endings for a Dating Sim based on points

#1 Post by Plusle »

I'm making a dating sim where, depending on how you answer, you can get one of three endings - friendship, romance and 'special' romance. (romance but with an extra scene at the end).

I've tried to set up a points system for 'romance' points.
If you get 0-2 you get the friendship ending, 3-5 is the normal romance ending and 6 is special romance.

At the start of my code I've written;

Code: Select all

$ Rpoints = 0
and when you 'correctly' answer a question in the sim I've coded;

Code: Select all

    menu:

        "Let's take it easy for now.":
        
            jump take_it_easy
            
        "Don't worry, we will.":
        
            jump dw_we_will
         
        "Yeah! Come on, let's go train!":
            $ Rspoints += 1
            jump lets_go_train
(wasn't sure that I position that correctly)
But I keep getting the error;

Code: Select all

I'm sorry, but an uncaught exception occurred.

While running game code:
  File "game/script.rpy", line 2475, in script
  File "game/script.rpy", line 2475, in python
NameError: name 'romance_points' is not defined

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

Full traceback:
  File "/Users/Mich/Downloads/renpy-6.14.1-sdk/renpy/execution.py", line 266, in run
    node.execute()
  File "/Users/Mich/Downloads/renpy-6.14.1-sdk/renpy/ast.py", line 646, in execute
    renpy.python.py_exec_bytecode(self.code.bytecode, self.hide, store=self.store)
  File "/Users/Mich/Downloads/renpy-6.14.1-sdk/renpy/python.py", line 1172, in py_exec_bytecode
    exec bytecode in globals, locals
  File "game/script.rpy", line 2475, in <module>
    $ romance_points += 1
NameError: name 'romance_points' is not defined
I'm not sure what went wrong, or what this means? Can anyone help explain this to me?
I've seen variants of this asked already, but I can't seem to apply it to my game, sorry in advance if this is considered spam.

Asceai
Eileen-Class Veteran
Posts: 1258
Joined: Fri Sep 21, 2007 7:13 am
Projects: a battle engine
Contact:

Re: Setting up endings for a Dating Sim based on points

#2 Post by Asceai »

You seem to be calling that variable three different things, "Rpoints", "Rspoints" and "romance_points"

Try just using one of those in all 3 places.

Plusle
Newbie
Posts: 18
Joined: Sat Feb 08, 2014 6:50 am
Contact:

Re: Setting up endings for a Dating Sim based on points

#3 Post by Plusle »

Ah... You're right, I didn't realize that.. d'oh ><

Just changed it though and still getting an error.
Am i not positioning the point's addition properly?
Like.. if I'm in a menu, do I write the point addition next to/directly underneath the correct menu option or at the beginning of the corresponding beginning of text?

Code: Select all

I'm sorry, but an uncaught exception occurred.

While running game code:
  File "game/script.rpy", line 2475, in script
  File "game/script.rpy", line 2475, in python
NameError: name 'Rpoints' is not defined

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

Full traceback:
  File "/Users/Mich/Downloads/renpy-6.14.1-sdk/renpy/execution.py", line 266, in run
    node.execute()
  File "/Users/Mich/Downloads/renpy-6.14.1-sdk/renpy/ast.py", line 646, in execute
    renpy.python.py_exec_bytecode(self.code.bytecode, self.hide, store=self.store)
  File "/Users/Mich/Downloads/renpy-6.14.1-sdk/renpy/python.py", line 1172, in py_exec_bytecode
    exec bytecode in globals, locals
  File "game/script.rpy", line 2475, in <module>
    $ Rpoints += 1
NameError: name 'Rpoints' is not defined

Plusle
Newbie
Posts: 18
Joined: Sat Feb 08, 2014 6:50 am
Contact:

Re: Setting up endings for a Dating Sim based on points

#4 Post by Plusle »

Ah, I worked it out, I put the code
$ Rpoints = 0

before the label start text...

Asceai
Eileen-Class Veteran
Posts: 1258
Joined: Fri Sep 21, 2007 7:13 am
Projects: a battle engine
Contact:

Re: Setting up endings for a Dating Sim based on points

#5 Post by Asceai »

Plusle wrote:Ah, I worked it out, I put the code
$ Rpoints = 0

before the label start text...
Be careful about where you put that. If it happens before the game is running (like, in an 'init:' block or something), Rpoints won't be tracked in save games and stuff. If you meant that you put it after label start: that should be fine.

Plusle
Newbie
Posts: 18
Joined: Sat Feb 08, 2014 6:50 am
Contact:

Re: Setting up endings for a Dating Sim based on points

#6 Post by Plusle »

Excellent, thank you for your help :)

Plusle
Newbie
Posts: 18
Joined: Sat Feb 08, 2014 6:50 am
Contact:

Re: Setting up endings for a Dating Sim based on points

#7 Post by Plusle »

Having a different problem now,

I'm trying to make it so that there is a 'best' romance ending. If you have accumulated 3-5 romance points (rpoints) during the game, you see the normal romance ending, but if you manage to get all 6 romance points, you will get some additional text at the end.

I have tried coding it like this;

Code: Select all

    "You both walk away, hand in hand."
   
if rpoints = 6:
    
    jump specialromance
    
elif rpoints <= 5:
    
    jump end


label end:
return

label specialromance:

    show lloyd serious animate
    with dissolve
    l "Actually Reimi, wait a second."
But when I input this code I get the error;

Code: Select all

I'm sorry, but an uncaught exception occurred.

While running game code:
  File "game/script.rpy", line 2997, in script
SyntaxError: invalid syntax (script.rpy, line 2997)

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

Full traceback:
  File "/Users/Mich/Downloads/renpy-6.14.1-sdk/renpy/execution.py", line 266, in run
    node.execute()
  File "/Users/Mich/Downloads/renpy-6.14.1-sdk/renpy/ast.py", line 1394, in execute
    if renpy.python.py_eval(condition):
  File "/Users/Mich/Downloads/renpy-6.14.1-sdk/renpy/python.py", line 1206, in py_eval
    return eval(py_compile(source, 'eval'), globals, locals)
  File "/Users/Mich/Downloads/renpy-6.14.1-sdk/renpy/python.py", line 413, in py_compile
    raise e
SyntaxError: invalid syntax (script.rpy, line 2997)
Any idea on what I might be doing wrong?

User avatar
xela
Lemma-Class Veteran
Posts: 2481
Joined: Sun Sep 18, 2011 10:13 am
Contact:

Re: Setting up endings for a Dating Sim based on points

#8 Post by xela »

if rpoints == 6:
Like what we're doing? Support us at:
Image

Plusle
Newbie
Posts: 18
Joined: Sat Feb 08, 2014 6:50 am
Contact:

Re: Setting up endings for a Dating Sim based on points

#9 Post by Plusle »

Ah, thanks, will test it in a bit and update soon :)

Plusle
Newbie
Posts: 18
Joined: Sat Feb 08, 2014 6:50 am
Contact:

Re: Setting up endings for a Dating Sim based on points

#10 Post by Plusle »

All working now, thank you!

Plusle
Newbie
Posts: 18
Joined: Sat Feb 08, 2014 6:50 am
Contact:

Re: Setting up endings for a Dating Sim based on points

#11 Post by Plusle »

Just been gametesting my dating sim through again and I've realized the different endings are still not being prompted properly.
The code I have in place at the end is;

Code: Select all

if Fpoints and rpoints <=2:
    jump normalend
elif Fpoints > rpoints:
    jump friendshipend
elif rpoints >=3 & Fpoints <=3:
    jump romanceend
^ - changing the order of this code seems to determine which end will occur. Like only the top code goes through.
I've also checked that the points were labelled properly and they seem to be.

What am I doing wrong?

User avatar
Steamgirl
Veteran
Posts: 322
Joined: Sat Jul 28, 2012 4:39 am
Completed: My Cup of Coffee, Queen at Arms (co-wrote a battle scene)
Projects: Stranded Hearts, Emma: A Lady's Maid
Deviantart: steamgirlgame
Contact:

Re: Setting up endings for a Dating Sim based on points

#12 Post by Steamgirl »

The & sign might need to be && (not 100% sure about that one, as you probably would have gotten error of some sort if it was wrong.)

I would print the value of each of them to double check if maybe it's not adding up correctly.

Code: Select all

if Fpoints and rpoints <=2:
    "Fpoints: %(Fpoints)s"
    "rpoints: %(rpoints)s"
    jump normalend
elif Fpoints > rpoints:
    "Fpoints: %(Fpoints)s"
    "rpoints: %(rpoints)s"
    jump friendshipend
elif rpoints >=3 & Fpoints <=3:
    "Fpoints: %(Fpoints)s"
    "rpoints: %(rpoints)s"
    jump romanceend
Last edited by Steamgirl on Sat Feb 22, 2014 2:15 pm, edited 1 time in total.

Plusle
Newbie
Posts: 18
Joined: Sat Feb 08, 2014 6:50 am
Contact:

Re: Setting up endings for a Dating Sim based on points

#13 Post by Plusle »

Ah thanks! What do I need to add in the brackets? Sorry, I'm a complete noob at coding ><

User avatar
Steamgirl
Veteran
Posts: 322
Joined: Sat Jul 28, 2012 4:39 am
Completed: My Cup of Coffee, Queen at Arms (co-wrote a battle scene)
Projects: Stranded Hearts, Emma: A Lady's Maid
Deviantart: steamgirlgame
Contact:

Re: Setting up endings for a Dating Sim based on points

#14 Post by Steamgirl »

Nothing - that code is good to go I believe (although I did accidentally add a space behind Fpoints which I've now removed). It will use your default narrator and print something like:

Fpoints: 2
rpoints: 1

Plusle
Newbie
Posts: 18
Joined: Sat Feb 08, 2014 6:50 am
Contact:

Re: Setting up endings for a Dating Sim based on points

#15 Post by Plusle »

Brilliant! It works now, thank you so much! Phew phew phew

out of curiousity, do I need the code to show them how many points they got for it to work?

Post Reply

Who is online

Users browsing this forum: Ahrefs [Bot], Google [Bot]