Counter for lines of text for reference

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
Settle for Pocky
Regular
Posts: 33
Joined: Sun Jul 08, 2018 8:49 am
Contact:

Counter for lines of text for reference

#1 Post by Settle for Pocky »

I can't seem to find it on here and when I type in "counter" in the search box it freezes up, so maybe there is so much of it?

I would want something in the corner that would have the total line of text (each block) and what I'm on currently
(like 1/500, 2/500, 3/500, etc.) so it's easier for people testing and for me referencing back to something.

take care,
Patrick B.

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

Re: Counter for lines of text for reference

#2 Post by Imperf3kt »

Renpy has a pre built (or you can make your own) screen for that called the progress_screen
It makes use of renpy.seen
https://www.renpy.org/doc/html/other.ht ... gue_blocks
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

Settle for Pocky
Regular
Posts: 33
Joined: Sun Jul 08, 2018 8:49 am
Contact:

Re: Counter for lines of text for reference

#3 Post by Settle for Pocky »

Do I literally just copy/paste

renpy.count_seen_dialogue_blocks() ?

Because I'm having trouble doing it (so I know there's probably more to it)

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

Re: Counter for lines of text for reference

#4 Post by Imperf3kt »

Okay, so you have two options.
You can use the prebuilt screen that can be found in renpy common, or make your own.

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 ""
All you have to do is in your script, "show screen progress_screen"
Alternatively, you can "ShowMenu ("progress_screen")" from a screen, but you might need to add tag menu to the progress screen.

You'll also likely want to style the screen.


Or, you could show it in the dialogue:

Code: Select all

default new = renpy.count_newly_seen_dialogue_blocks()
default seen = renpy.count_seen_dialogue_blocks()
default total = renpy.count_dialogue_blocks()

label start:
    "Hi, you have read [seen] of [total] lines of dialogue. You read [new] of those since you last stared the game."
    
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

Settle for Pocky
Regular
Posts: 33
Joined: Sun Jul 08, 2018 8:49 am
Contact:

Re: Counter for lines of text for reference

#5 Post by Settle for Pocky »

So this is what I did
I changed the progress screens so they would match (it would just bring me to the error screen), not sure if a typo.

Code: Select all

#COUNT BLOCKS OF TEXTS

screen progress_screen:
    $ 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 ""

    
# CHARACTERS SMOOTHLY COMING IN

init python:
    define.move_transitions("ease", 0.6)

# The game starts here.

label start:
    
    show screen progress_screen

So what I get is in the corner in white numbers with black outlines
0 813/1376 and doesn't move from that spot
So it does start at 0, but no idea where it's getting the 813/1376 from

and that same thing happens when I try it the other way with the dialogue box.

I'm really sorry about this, I spent about a hour tinkering with it.

This code also starts on line 105 if that helps :/
Last edited by Settle for Pocky on Mon Oct 15, 2018 11:34 pm, edited 1 time in total.

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

Re: Counter for lines of text for reference

#6 Post by Imperf3kt »

What that means would be 0 dialogue blocks have been read since the game was started or loaded.
813/1376 would mean that 813 dialogue blocks have been seen (probably during testing) from 1376 total dialogue blocks.

If these numbers don't match what you expect to see, you might need to delete persistent data from the Ren'Py launcher
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

Settle for Pocky
Regular
Posts: 33
Joined: Sun Jul 08, 2018 8:49 am
Contact:

Re: Counter for lines of text for reference

#7 Post by Settle for Pocky »

https://vimeo.com/295393839

Ok I got it but last thing is how to reset so when I open it again it goes back to 0/how many lines there are (0/500) instead of keeping track from last time.

I owe you a ton

take care,
Pat

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

Re: Counter for lines of text for reference

#8 Post by Imperf3kt »

That should be taken care of by deleting persistent data.
Building the game should also clear it (in the built distribution)

I am not sure on this though, having never considered it.
Oh and in your video, for some reason, your browser never loses focus and blocks half the screen.
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

Settle for Pocky
Regular
Posts: 33
Joined: Sun Jul 08, 2018 8:49 am
Contact:

Re: Counter for lines of text for reference

#9 Post by Settle for Pocky »

Sorry about the video.

So yeah my plan was when people were to test out the game they could pick out exact lines with grammar or other problems but also able to start over from checkpoints and able to just show what line you currently on rather than how much you've gone through.

Your advice still helps for the future, thanks :)

Post Reply

Who is online

Users browsing this forum: Google [Bot]