[Solved] Point system not working?

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
Night130
Newbie
Posts: 13
Joined: Sun Apr 22, 2018 9:57 am
Contact:

[Solved] Point system not working?

#1 Post by Night130 » Wed Apr 25, 2018 11:27 pm

I'm trying to make a dating sims where depending on which menu choice you choose will add points to a character, that will affect the ending.
When you pick the same character twice, you will get their ending. But when I play the game, it only goes to the first ending I have writing down.
Here's my code:

Code: Select all

 default aurora_Point = 0
default aladdin_Point = 0
default eric_Point = 0
default cindy_Point = 0
label start: 

Code: Select all

 a "Why don't we do something else? I could show you the garden."
menu:
    "Actually, I don't really want to see.":
        jump no
    "I would love that!":
        $ aurora_Point = +1
        jump yes 
The character name changes, but the python code is the same for the rest

Code: Select all

 menu:
    "Go to the gardens":
        jump garden2
        $ aurora_Point = +2 

Code: Select all

 if aurora_Point == 2:
    jump auroraending 
If I choose random choice and not worry about trying to date a character, I still get the first ending written instead of jumping to the correct ending. I don't get an error or a traceback. If you need more code, let me know :)
Last edited by Night130 on Thu Apr 26, 2018 8:41 am, edited 1 time in total.

kivik
Miko-Class Veteran
Posts: 784
Joined: Fri Jun 24, 2016 5:58 pm
Contact:

Re: Point system not working?

#2 Post by kivik » Thu Apr 26, 2018 4:55 am

One way of testing this is to output all the variable values before the ending so you can see whether the variables are at the expected value. Then you can deduce whether the ending condition logic is broken, or the value assignment earlier in the game is incorrect.

By the way, I assume that when you have this code:

Code: Select all

$ aurora_Point = +1
You meant to add 1 to aurora? If that's the case, the code you actually want is:

Code: Select all

$ aurora_Point += 1
or

Code: Select all

$ aurora_Point = aurora_Point + 1

Your code is basically assigning positive 1 to aurora_Point each time, not adding 1 to it.

User avatar
mitoky
Veteran
Posts: 287
Joined: Sat Feb 07, 2015 9:12 pm
Projects: CrossDol, The Purring Demon's Love, circus eterie
Organization: astellic
Tumblr: mitoky
Contact:

Re: Point system not working?

#3 Post by mitoky » Thu Apr 26, 2018 6:09 am

Maybe try switching the order? ("jump" at the very last):

Code: Select all

menu:
    "Go to the gardens":
        $ aurora_Point = +2
        jump garden2
         
Image

[Logo Commissions - OPEN] || Wish to support or tip me? Buy Me a Coffee!

Night130
Newbie
Posts: 13
Joined: Sun Apr 22, 2018 9:57 am
Contact:

Re: Point system not working?

#4 Post by Night130 » Thu Apr 26, 2018 8:40 am

Thank you both! That fixed it! The point value was wrong. Where I put

Code: Select all

  menu:
    "Go to the gardens":
        jump garden2
        $ aurora_Point = +2 
Should have been"

Code: Select all

  menu:
    "Go to the gardens":
        jump garden2
        $ aurora_Point = +1 
So, a +1 instead of a +2 :D

kivik
Miko-Class Veteran
Posts: 784
Joined: Fri Jun 24, 2016 5:58 pm
Contact:

Re: [Solved] Point system not working?

#5 Post by kivik » Thu Apr 26, 2018 9:45 am

Are you sure that's the correct code? You're still jumping before setting the variable, so it'd never reach the line that sets the variable?

User avatar
Remix
Miko-Class Veteran
Posts: 961
Joined: Tue May 30, 2017 6:10 am
Completed: None... yet (as I cannot draw very well)
Projects: An un-named 3d anime based trainer game
Contact:

Re: [Solved] Point system not working?

#6 Post by Remix » Fri Apr 27, 2018 5:09 am

kivik wrote:
Thu Apr 26, 2018 9:45 am
Are you sure that's the correct code? You're still jumping before setting the variable, so it'd never reach the line that sets the variable?
Knowing Ren'py, it might well still work as it probably runs the python parts through prediction :|

It does look wrong though and does make the code harder to quickly understand and therefore harder to maintain. I'd also suggest changing it so it reads in the order it runs (procedurally)
Night130 wrote:
Thu Apr 26, 2018 8:40 am
Should have been"

Code: Select all

        $ aurora_Point = +1 
So, a +1 instead of a +2 :D
You mean a 1, not a +1

As the other replies stated:
$ aurora_Point = +1
is exactly the same as
$ aurora_Point = 1

If you wanted aurora_Point to increase by one (e.g. from 1 to 2 or from 7 to 8 ) use:
$ aurora_Point += 1
(note where the + is)
Mad Scientist Todo List:
  • Finish Improved Event Handler
  • Implement DragonBones animation as a Creator Defined Container
  • Finish Catmull-Rom Spline pathing
  • Finish Bitmask collision and rebound vector system
  • Develop time based building mechanic
  • Others
  • *Find a superb artist and actually write a game*

Post Reply

Who is online

Users browsing this forum: No registered users