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.
-
InvertMouse
- Regular
- Posts: 95
- Joined: Sat May 31, 2014 3:41 am
- Completed: Unhack
- Organization: InvertMouse
- Location: Sydney, Australia
-
Contact:
#1
Post
by InvertMouse » Thu Feb 09, 2017 3:05 pm
So let's say:
label hello:
"Hello!"
"How are you?"
# GetLabel() - which should return 'hello'
"Okay bye now."
I wasn't able to work out if the current label gets stored anywhere, and if I load a save game say on the "How are you?" line, I wonder if Renpy will know which label I'm on? If I can work this out, I want to see if I can build some additional features on top.
Thank you

!
-
qirien
- Miko-Class Veteran
- Posts: 538
- Joined: Thu Jul 31, 2003 10:06 pm
- Organization: Metasepia Games
- Deviantart: qirien
- Github: qirien
- itch: qirien
- Location: New Mexico, USA
- Discord: qirien
-
Contact:
#2
Post
by qirien » Thu Feb 09, 2017 3:41 pm
I was thinking you could get it from the
return stack, but those don't seem to have labels in them, just filenames and some sort of index. Still, it might be the right place to start...
-
Apa
- Regular
- Posts: 103
- Joined: Fri Dec 23, 2016 2:26 am
- Location: NYC
-
Contact:
#3
Post
by Apa » Thu Feb 09, 2017 4:03 pm
I use following approach:
Code: Select all
init python:
def label_callback(name, abnormal):
store.current_label = name
config.label_callback = label_callback
...
label label_a:
"--> You are at [current_label]"
return
-
InvertMouse
- Regular
- Posts: 95
- Joined: Sat May 31, 2014 3:41 am
- Completed: Unhack
- Organization: InvertMouse
- Location: Sydney, Australia
-
Contact:
#4
Post
by InvertMouse » Thu Feb 09, 2017 5:25 pm
Awesome, thank you so much!
It looks like that solution doesn't let Renpy know which label you are on if you load back a save that is midway through a label/scene though, probably because the label change function doesn't get called when you load a save?
Speaking of which, is that a similar callback function I can listen for when I load a save file, or when I roll back to a previous line of dialogue?
Thank you

.
-
Apa
- Regular
- Posts: 103
- Joined: Fri Dec 23, 2016 2:26 am
- Location: NYC
-
Contact:
#5
Post
by Apa » Thu Feb 09, 2017 11:25 pm
InvertMouse wrote:It looks like that solution doesn't let Renpy know which label you are on if you load back a save that is midway through a label/scene though, probably because the label change function doesn't get called when you load a save?
You are right, I haven’t tested load functional at all.
Tho, I’d expect,
store.current_label is saved/restored properly along with any other variables.
Hopefully, PyTom can shed some light, what’s going on "under the hood"...?
InvertMouse wrote:Speaking of which, is that a similar callback function I can listen for when I load a save file, or when I roll back to a previous line of dialogue?
Yep, all callback function are
here.
-
trooper6
- Lemma-Class Veteran
- Posts: 3712
- Joined: Sat Jul 09, 2011 10:33 pm
- Projects: A Close Shave
- Location: Medford, MA
-
Contact:
#6
Post
by trooper6 » Fri Feb 10, 2017 1:58 am
May I ask what you want to know what label you are in for? And in which circumstance will you be writing some code (which usually happens in a label) while not knowing which label you are in? Some sort of screen situation?
Often times I find people want to do something and think they need some thing to do it...but there is often a simpler solution.
A Close Shave:
*Last Thing Done (Aug 17): Finished coding emotions and camera for 4/10 main labels.
*Currently Doing: Coding of emotions and camera for the labels--On 5/10
*First Next thing to do: Code in all CG and special animation stuff
*Next Next thing to do: Set up film animation
*Other Thing to Do: Do SFX and Score (maybe think about eye blinks?)
Check out My Clock Cookbook Recipe:
http://lemmasoft.renai.us/forums/viewto ... 51&t=21978
-
InvertMouse
- Regular
- Posts: 95
- Joined: Sat May 31, 2014 3:41 am
- Completed: Unhack
- Organization: InvertMouse
- Location: Sydney, Australia
-
Contact:
#7
Post
by InvertMouse » Fri Feb 10, 2017 2:35 am
Hi there trooper6

. Yeah, for sure. I want to write a story that alternates between two perspectives. Scene 1 is Mr A, 2 is Ms B, then back to Mr A, Ms B and so on. I want to have a different cursor and dialogue box design depending on whose perspective we are in, so when players load a saved game, I need to know which design to switch to.
-
trooper6
- Lemma-Class Veteran
- Posts: 3712
- Joined: Sat Jul 09, 2011 10:33 pm
- Projects: A Close Shave
- Location: Medford, MA
-
Contact:
#8
Post
by trooper6 » Fri Feb 10, 2017 2:43 am
I'm not certain you need a callback for what you want.
If you have images that will change depending on some variable (like who the POV character is), then you could do a lot with ConditionSwitch Images or if/else with styles. At the start of each label you set your pov variable and you are good. As for saving and loading, that shouldn't be a problem as long as you've declared all your variables properly using default.
A Close Shave:
*Last Thing Done (Aug 17): Finished coding emotions and camera for 4/10 main labels.
*Currently Doing: Coding of emotions and camera for the labels--On 5/10
*First Next thing to do: Code in all CG and special animation stuff
*Next Next thing to do: Set up film animation
*Other Thing to Do: Do SFX and Score (maybe think about eye blinks?)
Check out My Clock Cookbook Recipe:
http://lemmasoft.renai.us/forums/viewto ... 51&t=21978
-
InvertMouse
- Regular
- Posts: 95
- Joined: Sat May 31, 2014 3:41 am
- Completed: Unhack
- Organization: InvertMouse
- Location: Sydney, Australia
-
Contact:
#9
Post
by InvertMouse » Fri Feb 10, 2017 7:23 am
Awesome, thank you so much guys

. I will investigate some more and see what I can discover. Also, I will need to know how (if possible) to change textbox appearances at run time (not just per character but for a whole scene), but I will ask on a separate thread in case the answer helps anyone else out.
-
Apa
- Regular
- Posts: 103
- Joined: Fri Dec 23, 2016 2:26 am
- Location: NYC
-
Contact:
#10
Post
by Apa » Fri Feb 10, 2017 2:19 pm
trooper6 wrote:InvertMouse wrote:I want to write a story that alternates between two perspectives. Scene 1 is Mr A, 2 is Ms B, then back to Mr A, Ms B and so on. I want to have a different cursor and dialogue box design depending on whose perspective we are in, so when players load a saved game, I need to know which design to switch to.
I'm not certain you need a callback for what you want.
If you have images that will change depending on some variable (like who the POV character is), then you could do a lot with ConditionSwitch Images or if/else with styles. At the start of each label you set your pov variable and you are good.
I’d rather add a bit of code to a character itself, not "at the start of each label". Perspective (a global variable) changes when a character is about to say something or show up on the screen...
Textboxes, etc. can change their appearance according to the perspective variable too.
BTW: I’ve tested
config.label_callback with save/load and reported result
here.
-
trooper6
- Lemma-Class Veteran
- Posts: 3712
- Joined: Sat Jul 09, 2011 10:33 pm
- Projects: A Close Shave
- Location: Medford, MA
-
Contact:
#11
Post
by trooper6 » Sat Feb 11, 2017 1:45 am
Apa wrote:I’d rather add a bit of code to a character itself, not "at the start of each label". Perspective (a global variable) changes when a character is about to say something or show up on the screen...
Textboxes, etc. can change their appearance according to the perspective variable too.
BTW: I’ve tested
config.label_callback with save/load and reported result
here.
I don't know how the OP is structuring their game. It may not work to attach POV change to the character. Especially if the two characters interact. In the game Indigo Prophesy, the POV switches between three different characters, but these character also interact with each other. If it is possible to have Scene 1, POV Mr. A where he talks with Ms. B, and Scene 2, POV Ms. B where she talks with Mr. A, then having the POV switch whenever A or B is speaking would ruin the point.
And yes, I already pointed out that textboxes can change with the POV variable...I mentioned images (which text boxes are) and also styles.
A Close Shave:
*Last Thing Done (Aug 17): Finished coding emotions and camera for 4/10 main labels.
*Currently Doing: Coding of emotions and camera for the labels--On 5/10
*First Next thing to do: Code in all CG and special animation stuff
*Next Next thing to do: Set up film animation
*Other Thing to Do: Do SFX and Score (maybe think about eye blinks?)
Check out My Clock Cookbook Recipe:
http://lemmasoft.renai.us/forums/viewto ... 51&t=21978
-
Apa
- Regular
- Posts: 103
- Joined: Fri Dec 23, 2016 2:26 am
- Location: NYC
-
Contact:
#12
Post
by Apa » Sat Feb 11, 2017 3:02 am
trooper6 wrote:I don't know how the OP is structuring their game.
Yep, good internal game design is "everything". Bad one could easily take all the fun out of development...
-
GetOutOfMyLab
- Newbie
- Posts: 7
- Joined: Sun Apr 03, 2022 8:04 pm
-
Contact:
#13
Post
by GetOutOfMyLab » Thu Apr 14, 2022 6:25 pm
InvertMouse wrote: ↑Thu Feb 09, 2017 5:25 pm
Awesome, thank you so much!
It looks like that solution doesn't let Renpy know which label you are on if you load back a save that is midway through a label/scene though, probably because the label change function doesn't get called when you load a save?
Speaking of which, is that a similar callback function I can listen for when I load a save file, or when I roll back to a previous line of dialogue?
Thank you

.
I hate to necro this thread, but it had what I was looking for to get the current label. Some fine folks in the discord made some suggestions to make it work even when loading from a save. So here it is:
Code: Select all
init python:
def label_callback(name, abnormal):
ignored_labels = ["_after_load", "_start", "_quit", "_splashscreen", "_before_main_menu", "_main_menu", "_after_warp", "_hide_windows"]
if not name in ignored_labels:
store.current_label = name
config.label_callback = label_callback
Maybe this will help someone else looking for the same functionality.
Users browsing this forum: Ocelot