Known Bugs [SOLVED!]


Heya! I've been using this code to update my games and noticed a bug that I need to tell you all about.

If there is a text tag in the dialogue that's being grabbed, then it will count that as text characters being counted and style it according to the tag.

For example, if your dialogue looks like this in the engine:


Then it will look like this when grabbed, even when the limit is set to 25 characters.


Note how short the text actually is and note how the quotation mark at the end is colored.

Sometimes this doesn't cause issues, like when your sentence being grabbed starts with a bold tag or a color tag. Just keep wary if you have long tags (like font tags or image tags) because if it cuts off in the middle of the tag, then you may get an error when you access the save/load. So for now, I would recommend having text effects be at the end of the sentence to avoid this OR commenting out the last_phrase section.

I'll be looking into fixing this, but if you happen to get to it quicker than I can and you'd like to share, then please tell me so I can update this!

UPDATE: 

There's a fix now!  I will update the files on the itch page, but unfortunately I'm having internet problems so I won't be able to upload it right this moment.

For now though, in the current file find def the_lastline(d): in your code and replace what's there with the following:


    def the_lastline(d):

        mylast_line = getattr(store, '_last_raw_what', '',)

        line_take = renpy.substitute(renpy.filter_text_tags(mylast_line, allow=[]))[:25]

        d["last_line"] = line_take


so it will look like this:


And the problem should be fixed! This also allows for any player text input (like names) to be replaced with what was typed and not just a variable that could get cut in the middle.

Thanks so much to Feniks for the info and the help! :D

 ~Knickknack PJ

Get Ren'Py Save/Load Screen Overhaul, Seen Text Color, and Choices Code

Download NowName your own price

Comments

Log in with itch.io to leave a comment.

(1 edit) (+2)

I haven't tried this code, but wanted to mention that you should use https://www.renpy.org/doc/html/text.html#renpy.filter_text_tags to fix the text tag issue.
This will filter out text tags before you grab the first x characters :)

Oh and I should mention this as well: https://www.renpy.org/doc/html/other.html#renpy.substitute

You should use both to ensure you're not also accidentally cutting off variable substitutions (e.g. "Hey [name]" would be bad if it got cut off at "Hey [nam")

This can be accomplished in one line if necessary, e.g.

preview = renpy.substitute(renpy.filter_text_tags(TEXT_FOR_FILTERING, allow=[]))

Hope that helps!

I actually just found and implemented renpy.filter_text_tags before you posted this lmao, but thank you for bringing for renpy.substitute to my attention! I'll test this out. Thank you so much! :D

Wanted to let you know the code you provided works! Thank you so much! :D