[SOLVED] Mark label/chapter as "finished". Is it possible?

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
Nanahs
Veteran
Posts: 310
Joined: Wed Aug 22, 2018 5:50 pm
Contact:

[SOLVED] Mark label/chapter as "finished". Is it possible?

#1 Post by Nanahs »

I'm using a messenger code from here:
viewtopic.php?f=51&t=50153&start=105

The thing is, the player can access the phone at any time they want.
And sometimes they will get daily messages based on real time (month/day).

For example:

Code: Select all

label messenger:
    
    if month is 1 and day is 1:
        jump d0101
        

label d0101:

    show screen telegram

    python:    
        msg("Hello! what's up?", p=2, who=1)
Whenever they want to access their messenger chat, they will go to "label messenger".

So let's just say that they clicked on the messenger and there was a message for that day and play it.
If on the same day they click on the messenger again, "label messenger" with redirect them again to "label d0101" and will play it again.

What I want to know is if there's anything I can add at the end of the messenger conversation that "blocks" the person from playing it again.
When they click "label messenger" -> "label d0101", the messages will stay there as if they were a real conversation that the person had already answered.

To make it short:
Is that a anything I can add to the code that makes Renpy "understand" that they shouldn't go back to the beggining of "label d0101" but instead, jump to this part where the conversation already finished?

I believe it could be something like:

Code: Select all

label messenger:
    
    if month is 1 and day is 1:
        jump d0101
        

label d0101:
    
    if labelplayed:
        jump messenger
    if labelnotplayed:
        jump d0101begin
        
                
label d0101begin:

    show screen telegram

    python:    
        msg("Hello! what's up?", p=2, who=1)
        
###### END ALL CONVERSATION HERE ######

    $ labelplayed ()
I'm not sure though? :?: :oops:
Should I define "labelplayed" and "labelnotplayed"? How? It's been some time I don't use Renpy, so I'm kind of slow now :oops:

Since I'm not using "$ del_all_msg()" at the end, the "messenger" will keep the texts from "label d0101" on the chat.

Thank you so much.
Last edited by Nanahs on Mon Sep 28, 2020 10:53 pm, edited 2 times in total.

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

Re: Mark label/chapter as "finished". Is it possible?

#2 Post by Imperf3kt »

renpy.seen_label and other renpy.seen functions might work for you.
https://www.renpy.org/doc/html/label.ht ... seen_label
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
Nanahs
Veteran
Posts: 310
Joined: Wed Aug 22, 2018 5:50 pm
Contact:

Re: Mark label/chapter as "finished". Is it possible?

#3 Post by Nanahs »

Imperf3kt wrote: Sat Sep 26, 2020 7:06 pm renpy.seen_label and other renpy.seen functions might work for you.
https://www.renpy.org/doc/html/label.ht ... seen_label
Thank you so much! I'll try it :)

User avatar
Remix
Eileen-Class Veteran
Posts: 1628
Joined: Tue May 30, 2017 6:10 am
Completed: None... yet (as I'm still looking for an artist)
Projects: An un-named anime based trainer game
Contact:

Re: Mark label/chapter as "finished". Is it possible?

#4 Post by Remix »

Be aware though that renpy.seen_label is not reset per play through. If you've seen the label in any play through it will be listed there.
A label callback might be a better option or just add the label name to a defaulted list for relevant labels...

Code: Select all

default visited_messages = []
default valid_messages = []

label messenger:

    if month is 1 and day is 1:
        ## Add each message label to valid_messages - whether it has been seen or not
        $ valid_messages.append("d0101")

    # etc for other messages


    # prune valid_messages to only those not visited
    $ valid_messages = [k for k in valid_messages if k not in visited_messages]

    # iterate that list and jump/call each, remove it from valid and add it to visited
    while valid_messages:

        $ msg = valid_messages.pop(0)

        call expression msg

        # Add it to visited so we do not repeat it
        $ visited_messages.append(msg)

    return
        
label d0101:
     
    show screen telegram

        python:    
            msg("Hello! what's up?", p=2, who=1)

    return
Frameworks & Scriptlets:

User avatar
Nanahs
Veteran
Posts: 310
Joined: Wed Aug 22, 2018 5:50 pm
Contact:

Re: Mark label/chapter as "finished". Is it possible?

#5 Post by Nanahs »

Remix wrote: Mon Sep 28, 2020 2:49 pm Be aware though that renpy.seen_label is not reset per play through. If you've seen the label in any play through it will be listed there.
A label callback might be a better option or just add the label name to a defaulted list for relevant labels...

Code: Select all

default visited_messages = []
default valid_messages = []

label messenger:

    if month is 1 and day is 1:
        ## Add each message label to valid_messages - whether it has been seen or not
        $ valid_messages.append("d0101")

    # etc for other messages


    # prune valid_messages to only those not visited
    $ valid_messages = [k for k in valid_messages if k not in visited_messages]

    # iterate that list and jump/call each, remove it from valid and add it to visited
    while valid_messages:

        $ msg = valid_messages.pop(0)

        call expression msg

        # Add it to visited so we do not repeat it
        $ visited_messages.append(msg)

    return
        
label d0101:
     
    show screen telegram

        python:    
            msg("Hello! what's up?", p=2, who=1)

    return
Thank you so much! I'll give that a try too :)

Post Reply

Who is online

Users browsing this forum: Bing [Bot], Kia