[rated unnecessary] navigation system: while and break
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.
- Ayutac
- Regular
- Posts: 150
- Joined: Thu Oct 18, 2012 2:23 pm
- Projects: Pokémon Dating Sim
- Organization: A Breeze Of Science
- Deviantart: Ubro
- Location: Mayence, Germany
- Contact:
[rated unnecessary] navigation system: while and break
Hello there! I'm aware there is no break for while in Ren'Py and I should either use jumps directly or work with some control variable. However, my goal is not to use jumps because they remain in the stack and I would have very much of them. So using jumps is inappropiate and the control variables wouldn't work either if we happen to enter the same navigation point/loop twice, which is possible. Of course there is no problem to break a while loop within the python environment. But using this would force me to transform my menus into python code which would make the code more complicated. So I would need either the break in Ren'Py language (which would probably mean a lot of work for PyTom) or a nopython environment for within a python environment, I don't know if any of you know something about this. Or the third option is that one of you guys have another idea to solve my problem, by any chance.
I would also be interested how any of you coded a navigation system for your games, if any.
And I'm proud of my research xD
EDIT: related question: What is the python-equivalent to the return (of a call) of Ren'Py? Because it is not the return of python.
EDIT: The pop_return could be a solution, but I would judge it as a huge workaround where you have to keep track of where you actually came from. I would wish for a more simple solution.
EDIT: Should have attached my navigation.rpy (copyrighted with CC-BY-NC-SA) in the first place.
I would also be interested how any of you coded a navigation system for your games, if any.
And I'm proud of my research xD
EDIT: related question: What is the python-equivalent to the return (of a call) of Ren'Py? Because it is not the return of python.
EDIT: The pop_return could be a solution, but I would judge it as a huge workaround where you have to keep track of where you actually came from. I would wish for a more simple solution.
EDIT: Should have attached my navigation.rpy (copyrighted with CC-BY-NC-SA) in the first place.
- Attachments
-
- navigation.rpy
- (12.14 KiB) Downloaded 48 times
Last edited by Ayutac on Sat Jan 26, 2013 6:53 am, edited 3 times in total.
Up next: An original, open source, text-based Dating Sim. Stay tuned ;)
- astrobread
- Newbie
- Posts: 13
- Joined: Mon Jan 21, 2013 4:01 am
- Contact:
Re: navigation system: while and break OR nopython environme
Why wouldn't the control variable solution work? All you'd have to do is reset it directly prior to the while loop, and make sure that's the point your navigation targets. Alternatively, you could reset the control variable immediately after a loop ends in order to prep for the next time.
Based on the research you've listed I suspect I'm missing something. If there's a reason this won't work with your navigation system, could you post an example showing why?
Based on the research you've listed I suspect I'm missing something. If there's a reason this won't work with your navigation system, could you post an example showing why?
- PyTom
- Ren'Py Creator
- Posts: 15893
- Joined: Mon Feb 02, 2004 10:58 am
- Completed: Moonlight Walks
- Projects: Ren'Py
- IRC Nick: renpytom
- Github: renpytom
- itch: renpytom
- Location: Kings Park, NY
- Contact:
Re: navigation system: while and break OR nopython environme
Break is exactly equivalent to jump.Ayutac wrote:Hello there! I'm aware there is no break for while in Ren'Py and I should either use jumps directly or work with some control variable. However, my goal is not to use jumps because they remain in the stack and I would have very much of them. So using jumps is inappropiate and the control variables wouldn't work either if we happen to enter the same navigation point/loop twice, which is possible. Of course there is no problem to break a while loop within the python environment. But using this would force me to transform my menus into python code which would make the code more complicated. So I would need either the break in Ren'Py language (which would probably mean a lot of work for PyTom) or a nopython environment for within a python environment, I don't know if any of you know something about this. Or the third option is that one of you guys have another idea to solve my problem, by any chance.
I would also be interested how any of you coded a navigation system for your games, if any.
And I'm proud of my research xD
EDIT: related question: What is the python-equivalent to the return (of a call) of Ren'Py? Because it is not the return of python.
Code: Select all
while True:
if enemy_dead:
break
# Fighting code here.
Code: Select all
while True:
if enemy_dead:
jump done
# Fighting code here.
label done:
There is no proper python equivalent to Ren'Py return. You could do renpy.jump("_return"), which is a label that calls return, but it seems that your code is weirdly organized if you have to do this.
Supporting creators since 2004
(When was the last time you backed up your game?)
"Do good work." - Virgil Ivan "Gus" Grissom(When was the last time you backed up your game?)
"Silly and fun things are important." - Elon Musk
Software > Drama • https://www.patreon.com/renpytom
- Ayutac
- Regular
- Posts: 150
- Joined: Thu Oct 18, 2012 2:23 pm
- Projects: Pokémon Dating Sim
- Organization: A Breeze Of Science
- Deviantart: Ubro
- Location: Mayence, Germany
- Contact:
Re: navigation system: while and break OR nopython environme
I'll do your idea in pseudo code. "eW" is short for endWhileastrobread wrote:Why wouldn't the control variable solution work? All you'd have to do is reset it directly prior to the while loop, and make sure that's the point your navigation targets. Alternatively, you could reset the control variable immediately after a loop ends in order to prep for the next time.
Code: Select all
label world:
> jump town
> jump forest
> jump beach
label town:
eW[town] = False
while not eW:
> jump hotel
> jump library
> back to map (eW[town] = True)
label hotel:
eW[hotel] = False
while not eW:
> jump apartment
> back to town (eW[hotel] = True)
label forest:
eW[forest] = False
while not eW:
> go this direction
> go that direction
> occasionally end up in some place
label beach:
ew[beach] = False:
while not eW:
> drink something good
> go into forest
> back to map (eW[beach] = True)Another method would be to remove the labels change the parts to function calls instead. But from what I know, it seems the "def" command can only be used from within a python environment and like I said I try to keep it in Ren'Py, so another solution would be the existence of a nopython environment (with the python environment forbidden in it to prevent unnecessary nesting). Does this exist, or would it be difficult to implement?
So, are you basically saying I can leave my navigation how it is, because stack size wouldn't matter? When I have 31 days and say 200 jumps per day and a visit to the forest maze with length n*n, I would have 600 jumps + let's say 30*(n*n)/2. Let n be 100, that would be 150600 jumps per game. You say that amount of jumps wouldn't matter? If yes, I'll leave everything as it is.PyTom wrote:The call-stack issue seems irrelevant - you can't cause a break in an outer function in Python, and you can't cause a break in an outer while loop from an inner while loop in Ren'Py.
EDIT: Just went testing the thesis from before. I'm expecting results in one and a half hour. Generally, where is the upper limit for jump calls?
Up next: An original, open source, text-based Dating Sim. Stay tuned ;)
- nyaatrap
- Crawling Chaos
- Posts: 1824
- Joined: Mon Feb 13, 2012 5:37 am
- Location: Kimashi Tower, Japan
- Contact:
Re: navigation system: while and break OR nopython environme
I think you have mistaken "jump" and "call". renpy.jump is just a sequence flow and never return. Where jumped from is only recorded in the rollback function.
is equivalent to
BTW, if your have interested, I made a dungeon navigation system which is using renpy.show_screen and renpy.jump. http://lemmasoft.renai.us/forums/viewto ... 30&t=15755 The code is a bit unsophisticated, but It's a open source.
Code: Select all
label a:
pass
label b:
passCode: Select all
label a:
jump label b
label b:
pass- Ayutac
- Regular
- Posts: 150
- Joined: Thu Oct 18, 2012 2:23 pm
- Projects: Pokémon Dating Sim
- Organization: A Breeze Of Science
- Deviantart: Ubro
- Location: Mayence, Germany
- Contact:
Re: navigation system: while and break OR nopython environme
I managed to die during the prologue in the dungeon xD And I still know to less kanji to actually understand the dialogs.nyaatrap wrote:BTW, if your have interested, I made a dungeon navigation system which is using renpy.show_screen and renpy.jump. http://lemmasoft.renai.us/forums/viewto ... 30&t=15755 The code is a bit unsophisticated, but It's a open source.
But I looked through the source. The lack of commentary didn't make it easy and it took me a while to find the exploration label, but I see how this works.
The code for 160k jumps ran through, nothing exciting happened. I guess I can be relieved then and I better do mazes into a while loop, just in case.
Now it would be just interesting to know where the boundarys for the rollback stack are. I didn't understand rollback fully until know anyway :P
Up next: An original, open source, text-based Dating Sim. Stay tuned ;)
Who is online
Users browsing this forum: Bing [Bot]
