Getting the current dialogue string into a variable
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.
Getting the current dialogue string into a variable
I need to store current dialogue string in a variable, but I don't understand how to do that and I couldn't find any information about that anywhere. Any help, please? :c
- RicharDann
- Veteran
- Posts: 286
- Joined: Thu Aug 31, 2017 11:47 am
- Contact:
Re: Getting the current dialogue string into a variable
Probably the easiest method would be to add an action to the say screen. Then, whenever dialogue is presented to the player (by using RenPy's default dialogue system) the screen will update the variable for you. Of course it will continue to update it whenever dialogue changes, so it may not be what you want.
What would you be doing with this variable once it's stored?
Code: Select all
default current_dialogue = None # a variable that will hold current dialogue
# Say screen
screen say(who, what):
on 'show':
action SetVariable('current_dialogue', what) #sets current_dialogue to what
The most important step is always the next one.
Re: Getting the current dialogue string into a variable
Oh, that easy? I was thinking about something like that, but couldn't make it work. Thanks! >_<
I'll count an amout of characters in the string, I need it for one game feature that I can't explain shortly.
I'll count an amout of characters in the string, I need it for one game feature that I can't explain shortly.
Re: Getting the current dialogue string into a variable
Sorry, forgot... I need it to work with NVL mode.
- RicharDann
- Veteran
- Posts: 286
- Joined: Thu Aug 31, 2017 11:47 am
- Contact:
Re: Getting the current dialogue string into a variable
Hmmm, to be honest I'm not very familiar with the way NVL mode works internally, but taking a look at the documentation here, I suppose this could work:
This would cause the screen to immediately set the current_dialogue variable to the latest/current line displayed.
Code: Select all
screen nvl_dialogue(dialogue):
for d in dialogue:
window:
id d.window_id
fixed:
yfit gui.nvl_height is None
if d.who is not None:
text d.who:
id d.who_id
text d.what:
id d.what_id
## Add this two lines at the end, respecting the identation
if d.current:
timer .01 action SetVariable('current_dialogue', d.what)
This would cause the screen to immediately set the current_dialogue variable to the latest/current line displayed.
The most important step is always the next one.
Re: Getting the current dialogue string into a variable
It works! Thanks, again ^^
Who is online
Users browsing this forum: Ahrefs [Bot], Google [Bot], Nozori_Games