[Solved]Return to main menu after jumping to another label

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
findsome
Newbie
Posts: 8
Joined: Sun Apr 15, 2012 7:13 am
Contact:

[Solved]Return to main menu after jumping to another label

#1 Post by findsome »

[Solved]
Apparently I should be using the 'call' function instead of 'jump'.

Hi.

I have one main script file, and a events script file which the main script references.
The main script will be where the menus are, which jump to the various labels.
The events script is where the labels are, so the main script is supposed to reference then return to the main script file.

Example (very simplified)
Main script file:

Code: Select all

"Day 1"
"What should I do"
menu: 
    "eat":
        jump eat_test
    "sleep":
        jump sleep_test
    "Play":
        jump play_test

"Day 2"
"What should I do"
menu: 
    "eat":
        jump eat_test
    "sleep":
        jump sleep_test
    "Play":
        jump play_test
Event script file:

Code: Select all

label eat_test:
    "I ate"
    $ ate += 1
    return
label sleep_test:
    "I slept"
    $ sleep += 1
    return
label play_test:
    "I played"
    $ play += 1
    return
Expected:
Game reference events script file for the same events each day and add to the various variables.

Actual result:
Game brought back to main menu after choice selected on menu.

Am I using the return function wrongly, or is this how it is supposed to work?
If the return function is not to be used this way, may I know if there is anyway I can return to the main script after referencing the event script file? I do not want to use labels (ie "jump day1_ended", "label day1_ended:", etc) as the events are repeated each day, and I have 30+ days.

Thank you.
Last edited by findsome on Mon Jul 25, 2016 10:42 pm, edited 1 time in total.

User avatar
78909087
Veteran
Posts: 277
Joined: Sat Aug 16, 2014 2:33 pm
Completed: Dungeons and Don't Do It, Wake Up
Projects: Lethe
IRC Nick: Pacermist
Contact:

Re: Return to main menu after jumping to another label

#2 Post by 78909087 »

Using 'return' is the equivalent of saying 'The End'.
Try adding '()' to the end so that it is:

Code: Select all

label eat_test:
    "I ate"
    $ ate += 1
    return()
label sleep_test:
    "I slept"
    $ sleep += 1
    return()
label play_test:
    "I played"
    $ play += 1
    return()
And let me know how it works out.
I am not friends with the sun.
Image

User avatar
IrinaLazareva
Veteran
Posts: 399
Joined: Wed Jun 08, 2016 1:49 pm
Projects: Legacy
Organization: SunShI
Location: St.Petersburg, Russia
Contact:

Re: Return to main menu after jumping to another label

#3 Post by IrinaLazareva »

try

Code: Select all

init:
    $ ate = 0
    $ sleep = 0
    $ plays = 0
    $ days = 0
label start:

    $ days +=1
    "Day [days]"
    "What should I do"
    menu:
        "eat":
            jump eat_test
        "sleep":
            jump sleep_test
        "Play":
            jump play_test
        "New variables" if days>=3:
            jump next
     
label eat_test:
    "I ate"
    $ ate += 1
    jump start
label sleep_test:
    "I slept"
    $ sleep += 1
    jump start
label play_test:
    "I played"
    $ plays += 1
    jump start
    
label next:
    "..."
    return

User avatar
theCodeCat
Regular
Posts: 62
Joined: Sun Sep 06, 2015 8:40 pm
Projects: Lucid9, Mystic Destinies: Serendipity of Aeons
Skype: theCodeCat
Contact:

Re: Return to main menu after jumping to another label

#4 Post by theCodeCat »

Use 'call labelName' instead of 'jump labelName' if you want to return to that line at some point.

findsome
Newbie
Posts: 8
Joined: Sun Apr 15, 2012 7:13 am
Contact:

Re: Return to main menu after jumping to another label

#5 Post by findsome »

78909087 wrote:Using 'return' is the equivalent of saying 'The End'.
Try adding '()' to the end so that it is:

Code: Select all

label eat_test:
    "I ate"
    $ ate += 1
    return()
label sleep_test:
    "I slept"
    $ sleep += 1
    return()
label play_test:
    "I played"
    $ play += 1
    return()
And let me know how it works out.
Hi, I tried using the 'return()' function, but it still took me back to the main menu.

findsome
Newbie
Posts: 8
Joined: Sun Apr 15, 2012 7:13 am
Contact:

Re: Return to main menu after jumping to another label

#6 Post by findsome »

theCodeCat wrote:Use 'call labelName' instead of 'jump labelName' if you want to return to that line at some point.
Hi, yes, this works! Thank you very much for your help!

User avatar
Kate
Regular
Posts: 197
Joined: Thu Sep 19, 2013 6:10 pm
Projects: Blackout
Organization: Moonlight Otome
Location: United States
Contact:

Re: [Solved]Return to main menu after jumping to another lab

#7 Post by Kate »

Calls are your best friend for jumping around in a script with different menu options. Think of them as "diversions" and jumps more like "permanent" skips in the flow of the story coding.
Current Project:
Blackout [VN][Romance][GxB][Mystery][Suspense] http://lemmasoft.renai.us/forums/viewto ... 43&t=34118
"It is the duty of authors to make the fantastic seem ordinary and the ordinary seem fantastic." - K. Auer

Post Reply

Who is online

Users browsing this forum: No registered users