Help Coding a Progress Screen? [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
User avatar
xxmissarichanxx
Regular
Posts: 87
Joined: Thu Jul 11, 2013 1:37 am
Completed: Froot Basket Valentine, Devious
Projects: After-Party Chemistry, The Salaryman
Tumblr: xxmissarichanxx
Deviantart: xxmissarichanxx
itch: xxmissarichanxx
Location: US
Contact:

Help Coding a Progress Screen? [solved]

#1 Post by xxmissarichanxx »

Ollo! I need some help coding...

I'd like my game to count things that have been unlocked, kinda like how in Mermaid Splash (and maybe some other games, I can't really think of any right now...) counts the amount of endings you've collected, and it appears in a menu screen like, "7/18 endings unlocked" or something like that. But I'm not really sure how to go about doing that.

Not sure if persistent variables would work if you made it count each time something was unlocked, but some help would be appreciated... C:

Currently, my game uses a music room and image gallery code to show collected images and tracks, but I'd also like to include an overall progress screen.

I'd just like to have a progress screen where it would show something like this...

Music Tracks Unlocked 3/15
Endings Unlocked 0/4
CGs Unlocked 3/20

If you have any ideas, please let me know! Thank you very much! Cx
Last edited by xxmissarichanxx on Mon Aug 05, 2019 9:08 pm, edited 1 time in total.

User avatar
Imperf3kt
Lemma-Class Veteran
Posts: 3792
Joined: Mon Dec 14, 2015 5:05 am
itch: Imperf3kt
Location: Your monitor
Contact:

Re: Help Coding a Progress Screen?

#2 Post by Imperf3kt »

Renpy already includes an achievement tracker if you use achievements, you could use that.
https://www.renpy.org/doc/html/achievem ... t.progress

There's also a couple of built in screens (probably more useful for development than actual gameplay)

Code: Select all

    show screen _progress
    show screen _performance
The _progress screen could be used to add what you want, or you could make an entirely new screen.
Lets use whats already in Ren'Py and expand upon it.

Code: Select all

screen _progress:
    $ new = renpy.count_newly_seen_dialogue_blocks()
    $ seen = renpy.count_seen_dialogue_blocks()
    $ total = renpy.count_dialogue_blocks()

    drag:
        draggable True
        focus_mask None
        xpos 0
        ypos 0

        text "[new] [seen]/[total]":
            size 60
            color "#fff"
            outlines [ (1, "#000", 0, 0) ]
            alt ""
As you can see, this screen simply displays some text based on screen variables.
So to do what you want, use the same logic, add some new variables and points and adjust them as necessary within your script.

Code: Select all

default music_unlocks = 0
default ending_unlocks = 0
default cg_unlocks = 0

screen _progress:
    $ music = music_unlocks
    $ endings = ending_unlocks
    $ cg = cg_unlocks

    vbox:
        text "[music] of 15 music files unlocked"
        text "[endings] of 4 endings unlocked"
        text "[cg] of 20 Gallery items unlocked"


label start:
    "You unlocked a music file"
    $ music_unlocks += 1
    "You unlocked a CG"
    $ cg_unlocks += 1
    "You have reached ending one of four"
    $ending_unlocks += 1
There's a small issue with this though, if a player replays this section of your game, they'll get more points for something they've already done. It also won't save the data between different playthroughs, so lets add some checks to see if we've already got the [ending, music, cg, etc] using lists and persistent data.

Code: Select all

default persistent.music_unlocks = 0
default persistent.ending_unlocks = 0
default persistent.cg_unlocks = 0

screen _progress:
    $ music = persistent.music_unlocks
    $ endings = persistent.ending_unlocks
    $ cg = persistent.cg_unlocks

    vbox:
        text "[music] of 15 music files unlocked"
        text "[endings] of 4 endings unlocked" 
        text "[cg] of 20 Gallery items unlocked"


default persistent.music_file = []
default persistent.cg_file = []
default persistent.end_file = []


label testing_this:
    if "music_file_1" not in persistent.music_file:
        "You unlocked a music file."
        $ persistent.music_file.append("music_file_1")
        $ persistent.music_unlocks += 1
    else:
        "You already unlocked this music file."
        
    if "cg_file_1" not in persistent.cg_file:
        "You unlocked a CG."
        $ persistent.cg_file.append("cg_file_1")
        $ persistent.cg_unlocks += 1
    else:
        "You already unlocked this Gallery item."
        
    if "end_file_1" not in persistent.end_file:
        "You have reached ending one of four."
        $ persistent.end_file.append("end_file_1")
        $ persistent.ending_unlocks += 1
    else:
        "You reached ending one of four."
        "You have already unlocked this ending."
        
    return
Warning: May contain trace amounts of gratuitous plot.
pro·gram·mer (noun) An organism capable of converting caffeine into code.

Current project: GGD Mentor

Twitter

User avatar
xxmissarichanxx
Regular
Posts: 87
Joined: Thu Jul 11, 2013 1:37 am
Completed: Froot Basket Valentine, Devious
Projects: After-Party Chemistry, The Salaryman
Tumblr: xxmissarichanxx
Deviantart: xxmissarichanxx
itch: xxmissarichanxx
Location: US
Contact:

Re: Help Coding a Progress Screen?

#3 Post by xxmissarichanxx »

Imperf3kt wrote: Mon Aug 05, 2019 7:28 am Renpy already includes an achievement tracker if you use achievements, you could use that.
https://www.renpy.org/doc/html/achievem ... t.progress

There's also a couple of built in screens (probably more useful for development than actual gameplay)

Code: Select all

    show screen _progress
    show screen _performance
The _progress screen could be used to add what you want, or you could make an entirely new screen.
Lets use whats already in Ren'Py and expand upon it.

Code: Select all

screen _progress:
    $ new = renpy.count_newly_seen_dialogue_blocks()
    $ seen = renpy.count_seen_dialogue_blocks()
    $ total = renpy.count_dialogue_blocks()

    drag:
        draggable True
        focus_mask None
        xpos 0
        ypos 0

        text "[new] [seen]/[total]":
            size 60
            color "#fff"
            outlines [ (1, "#000", 0, 0) ]
            alt ""
As you can see, this screen simply displays some text based on screen variables.
So to do what you want, use the same logic, add some new variables and points and adjust them as necessary within your script.

Code: Select all

default music_unlocks = 0
default ending_unlocks = 0
default cg_unlocks = 0

screen _progress:
    $ music = music_unlocks
    $ endings = ending_unlocks
    $ cg = cg_unlocks

    vbox:
        text "[music] of 15 music files unlocked"
        text "[endings] of 4 endings unlocked"
        text "[cg] of 20 Gallery items unlocked"


label start:
    "You unlocked a music file"
    $ music_unlocks += 1
    "You unlocked a CG"
    $ cg_unlocks += 1
    "You have reached ending one of four"
    $ending_unlocks += 1
There's a small issue with this though, if a player replays this section of your game, they'll get more points for something they've already done. It also won't save the data between different playthroughs, so lets add some checks to see if we've already got the [ending, music, cg, etc] using lists and persistent data.

Code: Select all

default persistent.music_unlocks = 0
default persistent.ending_unlocks = 0
default persistent.cg_unlocks = 0

screen _progress:
    $ music = persistent.music_unlocks
    $ endings = persistent.ending_unlocks
    $ cg = persistent.cg_unlocks

    vbox:
        text "[music] of 15 music files unlocked"
        text "[endings] of 4 endings unlocked" 
        text "[cg] of 20 Gallery items unlocked"


default persistent.music_file = []
default persistent.cg_file = []
default persistent.end_file = []


label testing_this:
    if "music_file_1" not in persistent.music_file:
        "You unlocked a music file."
        $ persistent.music_file.append("music_file_1")
        $ persistent.music_unlocks += 1
    else:
        "You already unlocked this music file."
        
    if "cg_file_1" not in persistent.cg_file:
        "You unlocked a CG."
        $ persistent.cg_file.append("cg_file_1")
        $ persistent.cg_unlocks += 1
    else:
        "You already unlocked this Gallery item."
        
    if "end_file_1" not in persistent.end_file:
        "You have reached ending one of four."
        $ persistent.end_file.append("end_file_1")
        $ persistent.ending_unlocks += 1
    else:
        "You reached ending one of four."
        "You have already unlocked this ending."
        
    return
Oh my gosh! Thank you so much! This was very helpful and thorough! This is exactly what I was looking for. Thank you for also explaining every step too! I appreciate it a lot. C:

Post Reply

Who is online

Users browsing this forum: bananamilk, Bing [Bot]