So, yeah; topic title.
It may seem like a simple question considering how long I've been active on these forums.
But for the life of me, I can't make my brain come up with a reasonable explanation.
Before I start throwing it into my code, I just want to be clear.
Something simpler as well; the "return" keyword baffles me, especially on its own, when it's not returning a variable.
EDIT: In clear English, please.
[Solved]What exactly do the "pass" and "return" keywords do?
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.
- squark
- Veteran
- Posts: 277
- Joined: Fri Aug 17, 2007 9:59 am
- Completed: Tour de Pharmacy (Proofreader), The Abandoned Land: Book One (Proofreader)
- Projects: Raven Hollow (Core Coder, Proofreader), The Universal Hope (Core Coder, Proofreader)
- Organization: FlareBlue Entertainment
- Location: Always somewhere behind you...
- Contact:
[Solved]What exactly do the "pass" and "return" keywords do?
Last edited by squark on Tue Jan 29, 2013 7:00 am, edited 1 time in total.
Without communication, nothing is possible.
Universal Hope Stalled
Raven Hollow (on hold for now)
"All we see or seem
Is but a dream within a dream.
I stand amid the roar
Of a surf-tormented shore"
-- Edgar Allen Poe, "A Dream Within A Dream"
Current Projects:Is but a dream within a dream.
I stand amid the roar
Of a surf-tormented shore"
-- Edgar Allen Poe, "A Dream Within A Dream"
Universal Hope Stalled
Raven Hollow (on hold for now)
Peace and Love,
Squark
Squark
- 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: What exactly do the "pass" and "return" keywords do?
"pass" does nothing. It is indeed the clear instruction to do nothing. There are situations when this comes in handy, see example in next post (thanks, KimiYoriBaka).
Constructs like if always need a command after them, but if you literally want nothing to happen but have to give a command, pass is used. I just don't know if it's used in Python or Ren'Py xD
As for "return", it has different meanings. If used in Ren'Py, it returns the executing code to the point where you last usedwhere "labelName" is – who would have guessed it – the name of a label. However, if you have no "call" running at the moment, it returns to the game menu, so the actual game will be ended. Without asking to save, I might add. This return has a Python equivalent (end of post).
In Python "return" behaves different. It will simply return from the currently executing method to where the method was called from, occasionally returning a value which can be read. If no value is returned, you better try not to read anything.
Any questions left?
Constructs like if always need a command after them, but if you literally want nothing to happen but have to give a command, pass is used. I just don't know if it's used in Python or Ren'Py xD
As for "return", it has different meanings. If used in Ren'Py, it returns the executing code to the point where you last used
Code: Select all
call labelNameIn Python "return" behaves different. It will simply return from the currently executing method to where the method was called from, occasionally returning a value which can be read. If no value is returned, you better try not to read anything.
Any questions left?
Last edited by Ayutac on Mon Jan 28, 2013 12:30 am, edited 1 time in total.
Up next: An original, open source, text-based Dating Sim. Stay tuned ;)
- KimiYoriBaka
- Miko-Class Veteran
- Posts: 636
- Joined: Thu May 14, 2009 8:15 pm
- Projects: Castle of Arhannia
- Contact:
Re: What exactly do the "pass" and "return" keywords do?
just thought I'd add an example of "pass" that's a bit more useful and relevant.
if you have a set of choices that may or may not actually cause something to happen, then you can use "pass" to tell renpy that you don't want a choice to do anything.
if you have a set of choices that may or may not actually cause something to happen, then you can use "pass" to tell renpy that you don't want a choice to do anything.
Code: Select all
menu:
j "hey hey, watch me juggle these knives!!"
"Watch him juggle":
"The juggler successfully juggles a bunch of knives as I stare in awe."
"Ignore him and continue walking":
pass
"We continue walking."- squark
- Veteran
- Posts: 277
- Joined: Fri Aug 17, 2007 9:59 am
- Completed: Tour de Pharmacy (Proofreader), The Abandoned Land: Book One (Proofreader)
- Projects: Raven Hollow (Core Coder, Proofreader), The Universal Hope (Core Coder, Proofreader)
- Organization: FlareBlue Entertainment
- Location: Always somewhere behind you...
- Contact:
Re: What exactly do the "pass" and "return" keywords do?
Thanks, guys. This makes it very easy to follow ^^
Without communication, nothing is possible.
Universal Hope Stalled
Raven Hollow (on hold for now)
"All we see or seem
Is but a dream within a dream.
I stand amid the roar
Of a surf-tormented shore"
-- Edgar Allen Poe, "A Dream Within A Dream"
Current Projects:Is but a dream within a dream.
I stand amid the roar
Of a surf-tormented shore"
-- Edgar Allen Poe, "A Dream Within A Dream"
Universal Hope Stalled
Raven Hollow (on hold for now)
Peace and Love,
Squark
Squark
Who is online
Users browsing this forum: Google [Bot], _ticlock_

