Does Renpy have builtin jump & return point functionality?

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
henvu50
Veteran
Posts: 337
Joined: Wed Aug 22, 2018 1:22 am
Contact:

Does Renpy have builtin jump & return point functionality?

#1 Post by henvu50 »

Here is an example of what I'm looking to do:

Code: Select all


personX "hello, how are you?"
jumpReturn dialogue50
personX "i'm doing great.

label dialogue50:
personY: "i'm good and you?"

instead of just jump, I want to jump and return to the exact line where jumpReturn took place.

Result:

personX: "hello, how are you?"
personY: "I'm good and you?"
personX: "I'm doing great."

But why do I need this functionality? I want to avoid repeating the same lines of say dialogue during branching dialogue options.

Code: Select all


background image [standing in front of each other]

"I hate you, but I'll hug you.":
   personx "I hate you, but your family."
   jumpReturn hugGeneric
   personx "Ok, so back to not hugging you and just hating you."
 "I love you and I'll hug you.":
   personx "Yes, I do care about you."
   jumpReturn hugGeneric
   personx "ok, back to not hugging you and just loving you."
 "I'm not sure how I feel, but fine I'll hug you."
   personx "I'm not sure why I'm doing this."
   jumpReturn hugGeneric
   personx "ok back to not hugging you and just being confused."
   
label hugGeneric:
  background image [hugging]
  personX: "this is so nice."
  personY: "it sure is."
I'm trying to avoid this:

Code: Select all


background image [standing in front of each other]

"I hate you, but I'll hug you.":
   personx "I hate you, but your family."
   // repeating code
   background image [hugging]
   personX: "this is so nice."
   personY: "it sure is."
   // repeating code
   personx "Ok, so back to not hugging you and just hating you."
 "I love you and I'll hug you.":
   personx "Yes, I do care about you."
   // repeating code
   background image [hugging]
   personX: "this is so nice."
   personY: "it sure is."[/b]
   // repeating code
   personx "ok, back to not hugging you and just loving you."
 "I'm not sure how I feel, but fine I'll hug you."
   personx "I'm not sure why I'm doing this."
   // repeating code
   background image [hugging]
   personX: "this is so nice."
   personY: "it sure is."
   // repeating code
   personx "ok back to not hugging you and just being confused."
 
See how the code repeats?

User avatar
trooper6
Lemma-Class Veteran
Posts: 3712
Joined: Sat Jul 09, 2011 10:33 pm
Projects: A Close Shave
Location: Medford, MA
Contact:

Re: Does Renpy have builtin jump & return point functionality?

#2 Post by trooper6 »

Yes it does, it described in the documentation. You are looking for call.
https://www.renpy.org/doc/html/label.ht ... -statement

It would look like this:

Code: Select all

label start():
    "Game starts here."
    menu:
        "How do you feel about me?"
        "I hate you, but I'll hug you.":
             personx "I hate you, but your family."
              call hugGeneric()
              personx "Ok, so back to not hugging you and just hating you."
        "I love you and I'll hug you.":
              personx "Yes, I do care about you."
              call hugGeneric()
              personx "ok, back to not hugging you and just loving you."
        "I'm not sure how I feel, but fine I'll hug you.":
               personx "I'm not sure why I'm doing this."
               call hugGeneric()
               personx "ok back to not hugging you and just being confused."
    "Game ends here."
    return
       
label hugGeneric():
  background image [hugging]
  personX: "this is so nice."
  personY: "it sure is."
  return
A Close Shave:
*Last Thing Done (Aug 17): Finished coding emotions and camera for 4/10 main labels.
*Currently Doing: Coding of emotions and camera for the labels--On 5/10
*First Next thing to do: Code in all CG and special animation stuff
*Next Next thing to do: Set up film animation
*Other Thing to Do: Do SFX and Score (maybe think about eye blinks?)
Check out My Clock Cookbook Recipe: http://lemmasoft.renai.us/forums/viewto ... 51&t=21978

henvu50
Veteran
Posts: 337
Joined: Wed Aug 22, 2018 1:22 am
Contact:

Re: Does Renpy have builtin jump & return point functionality?

#3 Post by henvu50 »

Thank you. I will use call, however will it restore the original background image?

Code: Select all


label start():
    "Game starts here."
    background image "standingInFrontOfEachOther.jpg"
    menu:
        "How do you feel about me?"
        "I hate you, but I'll hug you.":
             personx "I hate you, but your family."
              call hugGeneric()
              personx "Ok, so back to not hugging you and just hating you."
        "I love you and I'll hug you.":
              personx "Yes, I do care about you."
              call hugGeneric()
              personx "ok, back to not hugging you and just loving you."
        "I'm not sure how I feel, but fine I'll hug you.":
               personx "I'm not sure why I'm doing this."
               call hugGeneric()
               personx "ok back to not hugging you and just being confused."
    "Game ends here."
    return
       
label hugGeneric():
  background image "hugging.jpg"
  personX: "this is so nice."
  personY: "it sure is."
  return

or do I need to add background image "standingInFrontOfEachOther.jpg" to every branch after making the call to hugGeneric?

i don't want to add background image "standingInFrontOfEachOther.jpg" to hugGeneric label.

Trying to avoid this:

Code: Select all


label start():
    "Game starts here."
    background image "standingInFrontOfEachOther.jpg"
    menu:
        "How do you feel about me?"
        "I hate you, but I'll hug you.":
             personx "I hate you, but your family."
              call hugGeneric()
               // want to avoid repeating lines like this
              background image "standingInFrontOfEachOther.jpg"
              personx "Ok, so back to not hugging you and just hating you."
        "I love you and I'll hug you.":
              personx "Yes, I do care about you."
              call hugGeneric()
               // want to avoid repeating lines like this
              background image "standingInFrontOfEachOther.jpg"
              personx "ok, back to not hugging you and just loving you."
        "I'm not sure how I feel, but fine I'll hug you.":
               personx "I'm not sure why I'm doing this."
               call hugGeneric()
               // want to avoid repeating lines like this
               background image "standingInFrontOfEachOther.jpg"
               personx "ok back to not hugging you and just being confused."
    "Game ends here."
    return
       
label hugGeneric():
  background image "hugging.jpg"
  personX: "this is so nice."
  personY: "it sure is."
  //want to avoid putting this here
  background image "standingInFrontOfEachOther.jpg"
  return

Spallidshorse
Newbie
Posts: 12
Joined: Thu Dec 08, 2016 3:13 pm
Contact:

Re: Does Renpy have builtin jump & return point functionality?

#4 Post by Spallidshorse »

While call does exactly the "jump - return" thing you're asking about, I would like to suggest that what you're thinking about doing here is kind of working against renpy and could cause some real headaches down the road! (and you're running into one of them right now by needing to re-type the background image after each call to hugGeneric) Specifically, I suggest thinking about how label, scene and show work.

Code: Select all

label start:                           #global label
    "game starts here."
     scene background            #scene calls a background image that wouldn't typically change until the next scene is called
     show speakers                 #show calls foreground images. These are typically more regularly access by the script during a given scene.
     menu:
        persY "How do you feel about me?"
        "I hate you, but I'll hug you.":
             persx "I hate you, but you're family."
             $emot = "hate"      
        "I love you and I'll hug you.":
              persx "Yes, I do care about you."
              $emot = "love"
        "I'm not sure how I feel, but fine I'll hug you.":
               persx "I'm not sure why I'm doing this."
               $emot = "uncertain"
       jump .the_hug             
      
label .the_hug:             #local label. not necessary here, but useful to keep in mind that you can do this, should you want to have similar things happen:
    hide speakers           #keeping this hug local to this event means you don't have to name it "the_hug_x_y_no_1" or whatever.
    show x_y_hugging     #so all I'm doing here is hiding the two foreground characters and replacing them with a new hugging foreground image

     persx "this is so nice."
     persy "it sure is."

    jump .end
    
label .end:
     hide x_y_hugging
     show speakers
    
    if emot == "hate":
        persx "Ok, so back to not hugging you and just hating you."
    elif emot == "love":              
       persx "ok, back to not hugging you and just loving you.
    elif emot == "uncertain":
        persx "ok back to not hugging you and just being confused."

    "Game ends here."
    return



The reason I'd advocate the above (and you can condense it further), is that splitting things into distinct story beats helps you to script things a lot more coherently, especially if you want to later refactor how you handle images for each speaker, animations, the code, etc.

henvu50
Veteran
Posts: 337
Joined: Wed Aug 22, 2018 1:22 am
Contact:

Re: Does Renpy have builtin jump & return point functionality?

#5 Post by henvu50 »

thanks

Post Reply

Who is online

Users browsing this forum: Sugar_and_rice