Dynamic Jump

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
Mirrodin
Regular
Posts: 114
Joined: Sun Mar 19, 2017 2:56 pm
Contact:

Dynamic Jump

#1 Post by Mirrodin »

Hi !

I work on my inventory this time.
I have an inventory label and at the end of the bisness i want the player go back at his precedent label.
So i made this :
$ lieu_actu is the precedant imagemap label name
I try this to :
- jump $ lieu_actu
- jump lieu_actu
- jump "%lieu_actu s"
- jump label "%lieu_actu s"

didnt work, what is the good syntax ?

Code: Select all

label inventaire:
    $ inventaire = [(objet.nom_fr, objet) for objet in inventaire_joueur.objets] 
    if len(inventaire_joueur.objets) ==0:
        "Je n'ai aucun objet sur moi"
    else:
        $ objet_choisi = menu(inventaire)
        $ entree = inventaire_joueur.objets.index(objet_choisi)
        $ objet_desc = objet_choisi.desc_fr
        $ objet_nom = objet_choisi.nom_fr
        "%(objet_nom)s : %(objet_desc)s"
        menu:
            "Boire" if objet_choisi.type =="soin":
                $ soin = objet_choisi.value1
                $ mana = objet_choisi.value2
                $ joueur.regenmana(mana)
                $ joueur.soin(soin)
                "vous récuperez [soin] pv"
                extend " et [mana] pm"
                $ del inventaire_joueur.objets[entree]
            "details":
                "%(objet_nom)s : %(objet_desc)s"
                jump label $ lieu_actu
            "retour":
                jump label $ lieu_actu
    jump label $ lieu_actu

User avatar
indoneko
Miko-Class Veteran
Posts: 528
Joined: Sat Sep 03, 2016 4:00 am
Contact:

Re: Dynamic Jump

#2 Post by indoneko »

Why do you have $ sign in front of your label name? :roll:

If your other label is lieu_actu, then the syntax will be jump lieu_actu

Perhaps it's better if you attach your script.rpy file here so that we can actually see how you're moving between labels.
My avatar is courtesy of Mellanthe

User avatar
Ocelot
Lemma-Class Veteran
Posts: 2400
Joined: Tue Aug 23, 2016 10:35 am
Github: MiiNiPaa
Discord: MiiNiPaa#4384
Contact:

Re: Dynamic Jump

#3 Post by Ocelot »

jump statement accept name of the label. Not the string containing name of the label, not something else.

Instead of trying to trow something and hope it will work (even if you succeeed, in programming, if something appears to work, and you cannot prove that it should work that way, it might stop working when you turn your back to it.), you should read the documentation.
https://www.renpy.org/doc/html/label.ht ... -statement
Documentation wrote:if the expression keyword is present, the expression following it is evaluated, and the string so computed is used as the name of the label to call.
So in your case, your statement should look like jump expression lieu_actu
< < insert Rick Cook quote here > >

User avatar
Mirrodin
Regular
Posts: 114
Joined: Sun Mar 19, 2017 2:56 pm
Contact:

Re: Dynamic Jump

#4 Post by Mirrodin »

Oh !
For the record, i read a lot documentation and other post, but sometime, like this stuff, i dont find.
yes i'm wizard apprentice, i try a lot of things, if its work, i try to do it clean, but a lot of time, i juste take some code and try to appropriate it for my need.
I will try like this.
thanks a lot.

User avatar
Mirrodin
Regular
Posts: 114
Joined: Sun Mar 19, 2017 2:56 pm
Contact:

Re: Dynamic Jump

#5 Post by Mirrodin »

I confirm, it work well
Ocelot : I accept u as my master :)

Post Reply

Who is online

Users browsing this forum: Google [Bot]