Ren'Py [SOLVED]Call, jump and call again ????

GoldenD

Member
Sep 30, 2018
102
70
Hi guys,
I have no more issue with this case but I don't understand the logic of operation.

Python:
default cpt = 0

label callLabel01:

    currentSpeaker "Begin First Call without return in code"
    call callLabel02
    currentSpeaker "End First Call without return in code"


label callLabel02:

    currentSpeaker "Begin Second Call without return in code"
    jump jumpLabel01
    currentSpeaker "End Second Call without return in code"
  


label jumpLabel01:
    $ cpt += 1

    currentSpeaker "Jump, cpt = [cpt]"
    return
How can you explain that after the jumpLabel01 is done, callLabel01 execute again the call callLabel02 ?

There is probably a logic answer but not for my little brain !!!
 
Last edited:

the66

beware, the germans are cumming
Modder
Donor
Respected User
Jan 27, 2017
7,808
24,388
because
currentSpeaker "Begin Second Call without return in code"
is the next processed statement after
currentSpeaker "End First Call without return in code".

call callLabel02 -> jump jumpLabel01 -> return (to the next statement after call callLabel02) -> jump jumpLabel01 -> return (the end)

currentSpeaker "End Second Call without return in code" is never reached.
 

anne O'nymous

I'm not grumpy, I'm just coded that way.
Modder
Donor
Respected User
Jun 10, 2017
10,963
16,201
As complement answer, in Ren'py, labels aren't enclosed blocks of code, like can be functions/procedures in other languages. You have to look at you code like something purely linear. Once a line is proceeded, Ren'py will pass to the next line, whatever where the said line is.

Which mean that, if you have something like :
Code:
label whatever:
    scene someScene
    mc "blablabla"
    show someImage    
    girl "blablabla"

init python:
    class myClass( renpy.python.RevertableObject ):
        [...]

default myVariable = None
define myList = [ "abc", "def", "ghi" ]

screen whatever():
   [....]

label anotherLabel:
    mc "Oops"

style myStyle is default:
    size 15

image myMovie = Movie( "someMovie.webm" )

girl "What am I doing here"
Ren'py will proceed it like this :
  • scene someScene
  • mc "blablabla"
  • show someImage
  • girl "blablabla"
  • mc "Oops"
  • girl "What am I doing here"

Therefore, it's a good habit to always end your label with a jump or a return statement (depending of the label), to ensure that you'll not have side effect like the one you encountered.
 

79flavors

Well-Known Member
Respected User
Jun 14, 2018
1,607
2,256
Or put a 3rd way...

return returns to the line after the latest call done... OR... to the game's main menu if no remaining call statements are outstanding.
RenPy will always* continue to line immediately below the current line (Except where the code uses specific commands which rely on indenting).
* There are bound to be exceptions to my use of "always".

So in your code...

You don't have permission to view the spoiler content. Log in or register now.
  • The game starts.
  • It reaches label callLabel01:
  • Displays "Begin First Call without return in code"
  • Then calls callLabel02
  • While there it displays "Begin Second Call without return in code"
  • It then jumps to jumpLabel01
  • Increases cpt by 1
  • Displays "Jump, cpt = 1"
  • Then returns to the line after call callLabel02
  • So it'll display "End First Call without return in code"
  • ... then continue to the next line... which happens to be label callLabel02:
  • While there it next displays "Begin Second Call without return in code"
  • Then jump again to jumpLabel01
  • Increases cpt by 1
  • Displays "Jump, cpt = 2"
  • Then with no more call entries in the program's call stack... it returns to the game's main menu.
The output probably looks like:
Code:
  Begin First Call without return in code
  Begin Second Call without return in code
  Jump, cpt = 1
  End First Call without return in code
  Begin Second Call without return in code
  Jump, cpt = 2
  *** END ***
I know you already have your answer... but I like to dumb things down for the next poor sucker who reads this thread.