Is it possible to get the current label?
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.
- InvertMouse
- Regular
- Posts: 95
- Joined: Sat May 31, 2014 3:41 am
- Completed: Unhack
- Organization: InvertMouse
- Location: Sydney, Australia
- Contact:
Is it possible to get the current label?
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 !
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: 542
- Joined: Thu Jul 31, 2003 10:06 pm
- Organization: Metasepia Games
- Deviantart: qirien
- Github: qirien
- itch: qirien
- Location: New Mexico, USA
- Discord: qirien
- Contact:
Re: Is it possible to get the current label?
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...
Re: Is it possible to get the current label?
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:
Re: Is it possible to get the current label?
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 .
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 .
Re: Is it possible to get the current label?
You are right, I haven’t tested load functional at all.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?
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"...?
Yep, all callback function are here.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?
- trooper6
- Lemma-Class Veteran
- Posts: 3712
- Joined: Sat Jul 09, 2011 10:33 pm
- Projects: A Close Shave
- Location: Medford, MA
- Contact:
Re: Is it possible to get the current label?
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.
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
*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:
Re: Is it possible to get the current label?
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:
Re: Is it possible to get the current label?
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.
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
*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:
Re: Is it possible to get the current label?
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.
Re: Is it possible to get the current label?
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...trooper6 wrote:I'm not certain you need a callback for what you want.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.
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.
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:
Re: Is it possible to get the current label?
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.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.
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
*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
Re: Is it possible to get the current label?
Yep, good internal game design is "everything". Bad one could easily take all the fun out of development...trooper6 wrote:I don't know how the OP is structuring their game.
-
- Newbie
- Posts: 11
- Joined: Sun Apr 03, 2022 8:04 pm
- Contact:
Re: Is it possible to get the current label?
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: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 .
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
Who is online
Users browsing this forum: Ahrefs [Bot]