[Solved]how to use the label twice

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
rayminator
Miko-Class Veteran
Posts: 793
Joined: Fri Feb 09, 2018 12:05 am
Location: Canada
Contact:

[Solved]how to use the label twice

#1 Post by rayminator »

ok just need a little help on using the label twice or is it not possible?

Code: Select all

menu:
        nav "selection"
        "Literal translation":
            jump literal <= I know that I have to use the if and else statements but how?
        "Summarize":
            jump summarize

    return

label literal: <= this what i have to use twice
Last edited by rayminator on Wed Apr 04, 2018 10:04 am, edited 1 time 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: how to use the label twice

#2 Post by Imperf3kt »

You can reuse labels and in some instances it can be very useful.

In your case, some simple logic should work, but I don't know what you're trying to do so I am not sure how to write it.
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

rayminator
Miko-Class Veteran
Posts: 793
Joined: Fri Feb 09, 2018 12:05 am
Location: Canada
Contact:

Re: how to use the label twice

#3 Post by rayminator »

i need it to use the label twice in a different route by using the same menu

route1 uses

Code: Select all

label literal:
and then route2 uses it as well

Code: Select all

label literal:

User avatar
Milkymalk
Miko-Class Veteran
Posts: 753
Joined: Wed Nov 23, 2011 5:30 pm
Completed: Don't Look (AGS game)
Projects: KANPEKI! ★Perfect Play★
Organization: Crappy White Wings
Location: Germany
Contact:

Re: how to use the label twice

#4 Post by Milkymalk »

I'm not sure I understand your problem. What's keeping you from jumping to a label from more than one point in the game?
If a label is used in more than one place, you better "call" the label and after you are finished there you can return to where you have been with "return":

Code: Select all

label start:
    "The game begins."
    call other_label
    "We are back."
    "Oops, forgot something."
    call other_label
    "Back again!"
    return
    
label other_label:
    "Taking a detour."
    return
Crappy White Wings (currently quite inactive)
Working on: KANPEKI!
(On Hold: New Eden, Imperial Sea, Pure Light)

rayminator
Miko-Class Veteran
Posts: 793
Joined: Fri Feb 09, 2018 12:05 am
Location: Canada
Contact:

Re: how to use the label twice

#5 Post by rayminator »

what I want to do is to reuse the menu so i don't have to recreate it that including the labels

instead of doing this


route 1

Code: Select all

menu:
        nav "selection"
        "Literal translation":
            jump literal
        "Summarize":
            jump summarize

    return

label literal: 

a "Hey what's up"
Route 2

Code: Select all

menu:
        nav "selection"
        "Literal translation":
            jump literal2
        "Summarize":
            jump summarize2

    return

label literal2: 

e "How is everything doing"

User avatar
Milkymalk
Miko-Class Veteran
Posts: 753
Joined: Wed Nov 23, 2011 5:30 pm
Completed: Don't Look (AGS game)
Projects: KANPEKI! ★Perfect Play★
Organization: Crappy White Wings
Location: Germany
Contact:

Re: how to use the label twice

#6 Post by Milkymalk »

Code: Select all

menu:
        nav "selection"
        "Literal translation":
            if route == 1:
                jump literal
            elif route == 2:
                jump literal2
        "Summarize":
            if route == 1:
                jump summarize
            elif route == 2:
                jump summarize2
Not much less to write than with two menus.
Last edited by Milkymalk on Wed Apr 04, 2018 3:57 pm, edited 1 time in total.
Crappy White Wings (currently quite inactive)
Working on: KANPEKI!
(On Hold: New Eden, Imperial Sea, Pure Light)

rayminator
Miko-Class Veteran
Posts: 793
Joined: Fri Feb 09, 2018 12:05 am
Location: Canada
Contact:

Re: how to use the label twice

#7 Post by rayminator »

Milkymalk wrote: Wed Apr 04, 2018 9:55 am

Code: Select all

menu:
        nav "selection"
        "Literal translation":
            if route == 1:
                jump literal
            elif route == 2:
                jump literal2
        "Summarize":
            if route == 1:
                jump summarize
            elif route == 2:
                jump summarize2
    return
Not much less to write than with two menus.
thanks for the help

Post Reply

Who is online

Users browsing this forum: No registered users