Returning to a previous line in Renpy
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.
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.
- pandajenni
- Newbie
- Posts: 3
- Joined: Wed Jan 27, 2016 11:50 am
- Contact:
Returning to a previous line in Renpy
I'm a renpy newbie and am in the process of creating a project using renpy. I managed to get the general programming to run, but I'm having a difficulty with return statements using the yes/no function. The line looks like this:
$layout.yesno_screen("Choose this music?", yes=NullAction(), no=Jump())
My goal is to get the no function to return to a previous line of coding for people to select another music choice. What would be the proper way to get the program to return to the previous line?
$layout.yesno_screen("Choose this music?", yes=NullAction(), no=Jump())
My goal is to get the no function to return to a previous line of coding for people to select another music choice. What would be the proper way to get the program to return to the previous line?
Re: Returning to a previous line in Renpy
Code: Select all
label returnPoint:
# other stuff goes here
$ layout.yesno_screen("Choose this music?", yes=Nullaction(), no=Jump("returnPoint"))
If we are what we repeatedly do, then good coding is not an act, but a habit
- pandajenni
- Newbie
- Posts: 3
- Joined: Wed Jan 27, 2016 11:50 am
- Contact:
Re: Returning to a previous line in Renpy
Thank you for that code! The return function is definitely working, however the yes/no screen is no longer popping up--it's creating this infinite loop somehow. I'm including some of the code to see if it's something that can be simply fixed. I really appreciate all of the help!
There are four other options of music as well, which is why I placed the return point at that location. Again, thanks for any input!
Code: Select all
scene Driving
"You are driving through a city with a lot of traffic (both cars and pedestrians). It is also raining very heavily outside. You want to make sure that you maintain focus on driving safely through this environment. You need to focus and pay careful attention to the road and traffic."
label returnPoint:
label MusicSelect:
"Please choose the music you would like to hear."
menu:
"GOAL: How would you keep your focus while driving?"
with dissolve
"[hap1]":
$layout.yesno_screen ("Choose this music?", yes=NullAction(), no=renpy.jump("returnPoint"))
jump choice_hap1Re: Returning to a previous line in Renpy
Its creating a loop because you're not altering anything after returning to the returnPoint.
If you have a list of music I suggest cycling through the index and increasing it by 1 each time the loop is performed e.g.
There are probably better ways of doing this but this is how I'd do it. I haven't tested the code above (as usual), but I hope you understand the concept.
If you have a list of music I suggest cycling through the index and increasing it by 1 each time the loop is performed e.g.
Code: Select all
label MusicSelect:
$ musicList = [musicA, musicB, etc] # make a list of music
$ index = -1 # (as index is incremented at the start of the loop, it needs to start at -1
label returnPoint:
python: # saves typing $ each line
index += 1 # increments the index
if index > len(musicList): # if the index would go past the end of the music list
index = 0 # start again at the beginning of the list
"Please choose the music you would like to hear."
menu:
"GOAL: How would you keep your focus while driving?"
with dissolve
"[musicList[index]]": # gets the music at the index
$layout.yesno_screen ("Choose this music?", yes=renpy.jump("choice_hap"), no=renpy.jump("returnPoint"))
label choice_hap:
"You have chosen music [musicList[index]]" # how to find which music was actually chosen.
If we are what we repeatedly do, then good coding is not an act, but a habit
Who is online
Users browsing this forum: Bing [Bot], Google [Bot]