Show number of unique endings achieved in main menu [Solved]

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
Iwako
Newbie
Posts: 19
Joined: Thu Mar 21, 2013 5:37 am
Contact:

Show number of unique endings achieved in main menu [Solved]

#1 Post by Iwako » Thu Dec 12, 2013 10:31 am

Hi >< Sorry this is probably a really stupid question. I'm trying to display how many endings finished in the main menu, and I followed this post: http://lemmasoft.renai.us/forums/viewto ... 29#p134417

It worked perfectly, up until I actually tried it. I probably messed up on the increasing persistent endings variable part (I basically just put $ persistent.endings_seen +=1 at the end of every ending), but I'm trying to get the number to only increase when I get a new different ending. Instead, even if I get the same ending over and over again, the number keeps on increasing >< I'm not sure how to fix that.

If anyone could help that'd be amazing. Thank you!
Last edited by Iwako on Fri Dec 13, 2013 8:16 am, edited 1 time in total.

User avatar
trooper6
Lemma-Class Veteran
Posts: 3712
Joined: Sat Jul 09, 2011 10:33 pm
Projects: A Close Shave
Location: Medford, MA
Contact:

Re: Show number of unique endings achieved in main menu?

#2 Post by trooper6 » Thu Dec 12, 2013 1:18 pm

I am on my iPad so I can't be totally specific, nor can I check the code in my own game, so I can't give you that info...but off the top of head, I can think of a couple different ways of doing it. In my game I wanted to keep track of easy specific ending achieved, but it looks like you just need the total number of endings achieved. So...

The first thing I can think of is that each ending has its own true/false variable which starts off as false.
For example: $ persistent.end1 = False

Then at the end of each of your individual ending blocks do an if statement like this:

Code: Select all

if persistent.end1 = false:
    $ persistent.end1 == true
    $ persistent.endings_seen += 1
Again, you'll have to check to make sure that is spelled right, but this idea checks to see if you've done the ending already. If yes, nothing happens. If no, it flags the ending complete and increases your ending seen variable.
A Close Shave:
*Last Thing Done (Aug 17): Finished coding emotions and camera for 4/10 main labels.
*Currently Doing: Coding of emotions and camera for the labels--On 5/10
*First Next thing to do: Code in all CG and special animation stuff
*Next Next thing to do: Set up film animation
*Other Thing to Do: Do SFX and Score (maybe think about eye blinks?)
Check out My Clock Cookbook Recipe: http://lemmasoft.renai.us/forums/viewto ... 51&t=21978

User avatar
xavimat
Eileen-Class Veteran
Posts: 1458
Joined: Sat Feb 25, 2012 8:45 pm
Completed: Yeshua, Jesus Life, Cops&Robbers
Projects: Fear&Love, unknown
Organization: Pilgrim Creations
Github: xavi-mat
itch: pilgrimcreations
Location: Spain
Contact:

Re: Show number of unique endings achieved in main menu?

#3 Post by xavimat » Thu Dec 12, 2013 4:38 pm

trooper6's idea seems fine, but the code seems not right:

Code: Select all

#Somewhere, in a .rpy file (outside a label):
init python:
    if persistent.endings_seen is None:
        persistent.endings_seen = 0

# At the end of every path:
if persistent.end1 is None:
    $ persistent.end1 = True
    $ persistent.endings_seen += 1
All the persistent.WHATEVER variables return None if they are not set, so, I think you need to set the 'persistent.endings_seen' variable to 0 before using it.

EDIT: corrected an error in python block
Last edited by xavimat on Fri Dec 13, 2013 4:26 pm, edited 1 time in total.
Comunidad Ren'Py en español: ¡Únete a nuestro Discord!
Rhaier Kingdom A Ren'Py Multiplayer Adventure Visual Novel.
Cops&Robbers A two-player experiment | Fear&Love Why can't we say I love you?
Honest Critique (Avatar made with Chibi Maker by ~gen8)

User avatar
trooper6
Lemma-Class Veteran
Posts: 3712
Joined: Sat Jul 09, 2011 10:33 pm
Projects: A Close Shave
Location: Medford, MA
Contact:

Re: Show number of unique endings achieved in main menu?

#4 Post by trooper6 » Thu Dec 12, 2013 5:17 pm

xavimat wrote:trooper6's idea seems fine, but the code seems not right:

Code: Select all

#Somewhere, in a .rpy file (outside a label):
init python:
    if persistent.endings_seen is None:
        $ persistent.endings_seen = 0

# At the end of every path:
if persistent.end1 is None:
    $ persistent.end1 = True
    $ persistent.endings_seen += 1
All the persistent.WHATEVER variables return None if they are not set, so, I think you need to set the 'persistent.endings_seen' variable to 0 before using it.
Good info xavimat! I had just imagined initializing all the persistent variables at the start block...I tend to do that by habit, but didn't explicitly say so.
A Close Shave:
*Last Thing Done (Aug 17): Finished coding emotions and camera for 4/10 main labels.
*Currently Doing: Coding of emotions and camera for the labels--On 5/10
*First Next thing to do: Code in all CG and special animation stuff
*Next Next thing to do: Set up film animation
*Other Thing to Do: Do SFX and Score (maybe think about eye blinks?)
Check out My Clock Cookbook Recipe: http://lemmasoft.renai.us/forums/viewto ... 51&t=21978

Iwako
Newbie
Posts: 19
Joined: Thu Mar 21, 2013 5:37 am
Contact:

Re: Show number of unique endings achieved in main menu?

#5 Post by Iwako » Fri Dec 13, 2013 5:54 am

Oh thank you so much! It makes a lot of sense.

However, I'm having a slight problem with the init code. I'm supposed to put

Code: Select all

init python:
    if persistent.endings_seen is None:
        $ persistent.endings_seen = 0
in a .rpy file outside of labels right? >< But I keep getting some syntax error whenever I get to that bit. Did I mess up anywhere?

Thank you again!

User avatar
xavimat
Eileen-Class Veteran
Posts: 1458
Joined: Sat Feb 25, 2012 8:45 pm
Completed: Yeshua, Jesus Life, Cops&Robbers
Projects: Fear&Love, unknown
Organization: Pilgrim Creations
Github: xavi-mat
itch: pilgrimcreations
Location: Spain
Contact:

Re: Show number of unique endings achieved in main menu?

#6 Post by xavimat » Fri Dec 13, 2013 6:44 am

Yes, my fault: the symbol $ is not needed inside a python block. Simply delete it.
Comunidad Ren'Py en español: ¡Únete a nuestro Discord!
Rhaier Kingdom A Ren'Py Multiplayer Adventure Visual Novel.
Cops&Robbers A two-player experiment | Fear&Love Why can't we say I love you?
Honest Critique (Avatar made with Chibi Maker by ~gen8)

Iwako
Newbie
Posts: 19
Joined: Thu Mar 21, 2013 5:37 am
Contact:

Re: Show number of unique endings achieved in main menu?

#7 Post by Iwako » Fri Dec 13, 2013 8:16 am

Oh! Works perfectly now. Thank you very much! :D

Post Reply

Who is online

Users browsing this forum: No registered users