Issue with custom narrator for different routes

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.
Post Reply
Message
Author
trailsiderice
Regular
Posts: 69
Joined: Fri Sep 29, 2023 4:02 pm
Contact:

Issue with custom narrator for different routes

#1 Post by trailsiderice »

So, I want to change the styling of the narrator dialogue based on which route the player is on, but I can't seem to change the narrator style.

The way I have it set up is like so:

Code: Select all

define nar = Character(None)
default narrator = nar

define route1_nar = Character(None, who_style="route1_namebox", what_style="route1_dialogue", window_style="route1_window")

define route2_nar = Character(None, who_style="route1_namebox", what_style="route1_dialogue", window_style="route1_window")
I want to have it so that the continue/start buttons set the narrator style, and I thought I could do that like this:

Code: Select all

action [Start(route.startlabel), SetVariable("narrator",route.id + "_nar")]
but that doesn't work. I don't get an error, but the dialogue styling for the narrator doesn't change.
I tried using defaults instead of defines for the nar, route1_nar, route2_nar, etc definitions, but that didn't work either.

I already know I can use the styling I want by typing route1_nar before all narration text in my script, but I'd rather avoid doing that, because having to type out the name of the narrator character every time I want to put in narration is tedious and annoying. I'd prefer to dynamically change the style of the default narrator so I don't have to type it out every time.

Is there a way to make this work?

User avatar
m_from_space
Eileen-Class Veteran
Posts: 1162
Joined: Sun Feb 21, 2021 3:36 am
Contact:

Re: Issue with custom narrator for different routes

#2 Post by m_from_space »

trailsiderice wrote: Sun Nov 19, 2023 2:41 amI don't get an error, but the dialogue styling for the narrator doesn't change.
In your code both the narrators are using the same styles, so what do you expect? :)

/edit
On the other hand, you're setting "narrator" variable to be a string. I have no clue what that will invoke internally. You have to set it to be an object.

Code: Select all

SetVariable("narrator", getattr(store, route.id+"_nar"))
/edit2

Also make sure to change the variable before using "Start", because otherwise it won't be executed I assume.

Code: Select all

action [ SetVariable("narrator", getattr(store, route.id+"_nar")), Start(route.startlabel) ]

trailsiderice
Regular
Posts: 69
Joined: Fri Sep 29, 2023 4:02 pm
Contact:

Re: Issue with custom narrator for different routes

#3 Post by trailsiderice »

m_from_space wrote: Sun Nov 19, 2023 7:42 am
trailsiderice wrote: Sun Nov 19, 2023 2:41 amI don't get an error, but the dialogue styling for the narrator doesn't change.
In your code both the narrators are using the same styles, so what do you expect? :)
They are definitely not the same. The default style is Character(None), which calls no style blocks for who_style or what_style, so defaults to the styling in gui.rpy. whereas the other variables link to different style blocks. I didn't include those style blocks because I figured it wasn't relevant, and because I thought it was self evident that they would be different from the gui.rpy defaults.
m_from_space wrote: Sun Nov 19, 2023 7:42 am /edit
On the other hand, you're setting "narrator" variable to be a string. I have no clue what that will invoke internally. You have to set it to be an object.

Code: Select all

SetVariable("narrator", getattr(store, route.id+"_nar"))
/edit2

Also make sure to change the variable before using "Start", because otherwise it won't be executed I assume.

Code: Select all

action [ SetVariable("narrator", getattr(store, route.id+"_nar")), Start(route.startlabel) ]
Ah, I didn't realize it mattered what order you put actions in when theyre in a list. I have up until now known them to execute at the same time, but maybe I was just lucky with how I was positioning them.

I'm not sure whether it was that or the fact that I was assigning it a string that caused the issue, but it must have been one (or both) of them, because I changed both and it seems to be working as intended now. Thank you for your help!

Post Reply

Who is online

Users browsing this forum: No registered users