SOLVED! (Unexpected Quotation Mark/Unexpected Line Break/Text Box Disappears During Side-Sprite Change)

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
User avatar
Offworlder
Regular
Posts: 114
Joined: Mon Aug 20, 2018 6:33 pm
Contact:

SOLVED! (Unexpected Quotation Mark/Unexpected Line Break/Text Box Disappears During Side-Sprite Change)

#1 Post by Offworlder »

I feel like I've been asking a lot of questions. I swear, I do try to figure it out on my own first.
...I apologize for being such a novice. x_x

This actually follows up from a question I asked before, in a way. I'm using "extend" in two different places. Both accomplish my main goal, but both display a small issue as well. Two different issues, actually.

First:

Code: Select all

show test at left with dissolve
l "Mission accomplished! {w=0.8}
\n.{w=0.4}.{w=0.4}.{w=0.4}{nw}"
show test2 at left with dissolve
extend "Ugh."
The intention of this script is to have the character speak the first part of their dialogue at default speed, pause for a moment, then automatically (without clicking) speak the rest of their dialogue on a new line with a short delay between each period in "...". All of that works perfectly fine!

The problem comes with the sprite image. The goal is to have the first expression appear along with the first part of the dialogue, as well as the "...". Then without clicking, have the second expression appear at the same time as "Ugh."

It ALMOST works, but the text box disappears during the split second needed for the expression to change, and "Ugh." doesn't write until the text box shows up again.

I'm not sure if this is due to an error in the code, or if I'll just need to use a different code.

Second:

Code: Select all

l "3...{w=0.5}2...{w=0.5}1...{w=0.5}{nw}"
play sound "sfx/sound.ogg"
extend "{w=2.5}\nBANG!"
For this section, the goal is for the character to speak with short delays between the numbers in the countdown, followed by a sound effect, followed by "BANG!" on a new line. All automatically, with no clicking needed.

Again, the code mostly works as intended. However, after the end of the countdown, a quotation mark appears for a split second. I actually noticed this happening with the code I described above as well, right before the text box disappears.

EDIT 1: I didn't think to mention this before, but my characters are defined in such a way that they speak with quotes:

Code: Select all

define l = Character("Liam", what_prefix='"', what_suffix='"')
Removing the "what_prefix/what suffix" section resolves the issue of a quotation mark appearing right when the sound effect starts/right after the first section of dialogue ends, but it does so by making the character not speak with quotes. I definitely don't want to just completely remove quotation marks from dialogue, so that doesn't entirely help. Hopefully, though, knowing this will help determine a workaround!

EDIT 2: Another issue that happens ONLY with the second code is that the dialogue moves down just slightly when the sound effect starts playing.

If anyone can help me resolve these issues -- either with an entirely new code, or something I can add to these codes so they work as intended --, I would greatly appreciate it!


All of the above issues were solved by the magnificent Kampmichi off-site!
Last edited by Offworlder on Sat Sep 15, 2018 9:37 pm, edited 4 times in total.

User avatar
Offworlder
Regular
Posts: 114
Joined: Mon Aug 20, 2018 6:33 pm
Contact:

Re: SOLVED!

#2 Post by Offworlder »

In case anyone else has this issue, the fix was deceptively simple (though required a workaround).

As described, my character was defined to use quotation marks whenever they speak. Like so:

Code: Select all

define l = Character("Liam", what_prefix='"', what_suffix='"')
Here's how the dialogue for both codes described in my first post looks in-game:
"Mission accomplished!
...Ugh."
AND
"3...2...1...
BANG!"
HOWEVER, after the first line of dialogue plays, Ren'py seems to expect that there should be an end-quote. As such, a quotation mark briefly flashes onto the screen. Ren'py immediately corrects itself, though, and said quotation mark disappears within a split second.

In order to fix this, a second character with the same name needs to be defined:

Code: Select all

define l = Character("Liam", what_prefix='"', what_suffix='"')
define l2 = Character("Liam")
For normal dialogue with nothing fancy happening, "l" would be used and the dialogue would be in quotes by default.
When something different needs to be done, however, like playing sound or changing sprites in the middle of dialogue, "l2" should be used instead. Then, quotes would be added to the dialogue manually like so:

Code: Select all

show test at left with dissolve
    l2 "\"Mission accomplished! {w=0.8}{nw}
    \n.{w=0.4}.{w=0.4}.{w=0.4}"
    show test2 at left
    extend "Ugh.\""
AND

Code: Select all

    l2 "\"3...{w=0.5}2...{w=0.5}1...{nw}\n"
    play sound "sfx/dinnerbell.ogg"
    extend "{w=2.5}BANG!\""
"\ before the first line of dialogue.
\" at the end of the last line of dialogue.
These are used for manual quotes, in case anyone isn't familiar!

I actually had an additional issue with the second code. The first line of dialogue would move down slightly once the sound effect began playing. The fix was easy, needing only to relocate the line break code (\n).

Original Placement:

Code: Select all

extend "{w=2.5}\nBANG!\""
Correct Placement:

Code: Select all

l2 "\"3...{w=0.5}2...{w=0.5}1...{nw}\n"
Lastly, the issue with my text box disappearing during the second it takes for my side-sprite to change expressions.
Apparently, having a transition for the expression change is what caused this. No transition, text box never disappears. I hope there's a workaround for this, though, as I think expression changes look better with a fade rather than being instant!

Post Reply

Who is online

Users browsing this forum: Ocelot, Rhapsy