Page 1 of 1

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

Posted: Mon Jul 25, 2016 6:17 am
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.

Re: Return to main menu after jumping to another label

Posted: Mon Jul 25, 2016 6:35 am
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.

Re: Return to main menu after jumping to another label

Posted: Mon Jul 25, 2016 9:54 am
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

Re: Return to main menu after jumping to another label

Posted: Mon Jul 25, 2016 10:37 am
by theCodeCat
Use 'call labelName' instead of 'jump labelName' if you want to return to that line at some point.

Re: Return to main menu after jumping to another label

Posted: Mon Jul 25, 2016 10:41 pm
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.

Re: Return to main menu after jumping to another label

Posted: Mon Jul 25, 2016 10:42 pm
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!

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

Posted: Tue Jul 26, 2016 2:53 pm
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.