[SOLVED] How to jump to a variable? Label name by variables.

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
KHTRE
Newbie
Posts: 3
Joined: Fri Dec 08, 2017 12:18 pm
Contact:

[SOLVED] How to jump to a variable? Label name by variables.

#1 Post by KHTRE »

Let's say, I have huge amount of labels (label ab, label ac, label ad etc.), sort of matrix.
I want person to enter "coordinates" and jump to specefic label.

Somethig like:

Code: Select all

    $ coord_x = "a"
    $ coord_y = "b"   
    jump [coord_x][coord_y]

label ab:
    "ab"
label ac:
    "ac" 
label ad:
    "ad" 

But Renpy doesn't want to work like this. Is there some way to do it?


I have found a solution!

Code: Select all

    $ coord_x = "a"
    $ coord_y = "b"
    $ coord_sum = coord_x+coord_y
    jump expression coord_sum
label ab:
    "ab"
Last edited by KHTRE on Sat Dec 09, 2017 9:45 am, edited 3 times in total.

User avatar
mitoky
Veteran
Posts: 316
Joined: Sat Feb 07, 2015 9:12 pm
Projects: The Purring Demon's Love, circus eterie
Contact:

Re: How to jump to a variable? Label name by variables.

#2 Post by mitoky »

Maybe something like:

Code: Select all

    if coord_xa and coord_yb:
        jump label ab
would work too?
Sorry if its not what you are looking for ><
Otherwise maybe someone more experienced maybe has a solution.

KHTRE
Newbie
Posts: 3
Joined: Fri Dec 08, 2017 12:18 pm
Contact:

Re: How to jump to a variable? Label name by variables.

#3 Post by KHTRE »

No, that won't help me. I will have to check every label. So this construction will be huge.

KHTRE
Newbie
Posts: 3
Joined: Fri Dec 08, 2017 12:18 pm
Contact:

Re: How to jump to a variable? Label name by variables.

#4 Post by KHTRE »

I have found a solution!

User avatar
Scribbles
Miko-Class Veteran
Posts: 636
Joined: Wed Sep 21, 2016 4:15 pm
Completed: Pinewood Island, As We Know It
Projects: In Blood
Organization: Jaime Scribbles Games
Deviantart: breakfastdoodles
itch: scribbles
Location: Ohio
Contact:

Re: How to jump to a variable? Label name by variables.

#5 Post by Scribbles »

you could try:

Code: Select all


jump expression str(coord_x) + str(coord_y)

though I see you said you found a solution, but just in case
Image - Image -Image

Post Reply

Who is online

Users browsing this forum: Google [Bot]