Label starts in the middle

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
hapciupalit
Newbie
Posts: 17
Joined: Tue Nov 13, 2018 6:00 am
Contact:

Label starts in the middle

#1 Post by hapciupalit » Wed Feb 19, 2020 11:23 am

Is it possible to create a way for the label to skip seen parts of a label?
I'm doing a chat system and you can exit anytime you want and open it the same way.
My problem is that everytime I open the chat label it starts from the beginning. I'm thinking on adding some id's to each of the lines or something, but I'm not sure how to skip to that part.

Anyone has some ideas on how to do that?

User avatar
Per K Grok
Miko-Class Veteran
Posts: 640
Joined: Fri May 18, 2018 1:02 am
Completed: the Ghost Pilot, Sea of Lost Ships, Bubbles and the Pterodactyls, Defenders of Adacan Part 1
Projects: Defenders of Adacan Part 2
Deviantart: pekj
itch: per-k-grok
Location: Sverige
Contact:

Re: Label starts in the middle

#2 Post by Per K Grok » Wed Feb 19, 2020 1:25 pm

hapciupalit wrote:
Wed Feb 19, 2020 11:23 am
Is it possible to create a way for the label to skip seen parts of a label?
I'm doing a chat system and you can exit anytime you want and open it the same way.
My problem is that everytime I open the chat label it starts from the beginning. I'm thinking on adding some id's to each of the lines or something, but I'm not sure how to skip to that part.

Anyone has some ideas on how to do that?
You could have a variable that starts of at 0. For each segment under the label you add + 1 to the variable. Each segment starts with an if segment.

if var_Id<1:
[do segment 1]
$ var_Id +=1

if var_Id<2:
[do segment 2]
$ var_Id +=1

if var_Id<3:
[do segment 3]
$ var_Id +=1

Next time you go to the label it will not play segments that already has been done.
Image Visual Story Telling, DeviantArt Group for animations, comics, games and illustrations https://www.deviantart.com/acgi

hapciupalit
Newbie
Posts: 17
Joined: Tue Nov 13, 2018 6:00 am
Contact:

Re: Label starts in the middle

#3 Post by hapciupalit » Wed Feb 19, 2020 3:17 pm

Per K Grok wrote:
Wed Feb 19, 2020 1:25 pm
hapciupalit wrote:
Wed Feb 19, 2020 11:23 am
Is it possible to create a way for the label to skip seen parts of a label?
I'm doing a chat system and you can exit anytime you want and open it the same way.
My problem is that everytime I open the chat label it starts from the beginning. I'm thinking on adding some id's to each of the lines or something, but I'm not sure how to skip to that part.

Anyone has some ideas on how to do that?
You could have a variable that starts of at 0. For each segment under the label you add + 1 to the variable. Each segment starts with an if segment.

if var_Id<1:
[do segment 1]
$ var_Id +=1

if var_Id<2:
[do segment 2]
$ var_Id +=1

if var_Id<3:
[do segment 3]
$ var_Id +=1

Next time you go to the label it will not play segments that already has been done.
Perfect. Thank you. I got one more question. Won't many ifs screw the performance? If for example I have a chat of 100 lines.

User avatar
Alex
Lemma-Class Veteran
Posts: 2427
Joined: Fri Dec 11, 2009 5:25 pm
Contact:

Re: Label starts in the middle

#4 Post by Alex » Wed Feb 19, 2020 3:27 pm

Also, you could try to do it like

Code: Select all

default lbl_name = None

label chat:
    if lbl_name:
        jump expression lbl_name # or $ renpy.jump(lbl_name)
    chat chat chat
    $ lbl_name = "chat_1"

label chat_1:
    chat chat chat
    $ lbl_name = "chat_2"

label chat_2:
    chat chat chat
    $ lbl_name = "chat_end"

label chat_end:
    "...nothing to say anymore..."

User avatar
Per K Grok
Miko-Class Veteran
Posts: 640
Joined: Fri May 18, 2018 1:02 am
Completed: the Ghost Pilot, Sea of Lost Ships, Bubbles and the Pterodactyls, Defenders of Adacan Part 1
Projects: Defenders of Adacan Part 2
Deviantart: pekj
itch: per-k-grok
Location: Sverige
Contact:

Re: Label starts in the middle

#5 Post by Per K Grok » Thu Feb 20, 2020 2:07 am

hapciupalit wrote:
Wed Feb 19, 2020 3:17 pm
---
I got one more question. Won't many ifs screw the performance? If for example I have a chat of 100 lines.
Writing those lines will probable be boring and tiring for you, but no problem for the computer to handle. :D
Image Visual Story Telling, DeviantArt Group for animations, comics, games and illustrations https://www.deviantart.com/acgi

hapciupalit
Newbie
Posts: 17
Joined: Tue Nov 13, 2018 6:00 am
Contact:

Re: Label starts in the middle

#6 Post by hapciupalit » Thu Feb 20, 2020 2:39 am

Thank you both. I'll see which is the simplest solution for me to write the text with.

Post Reply

Who is online

Users browsing this forum: twistkill