If you're having trouble or run into any bugs with the code, post a comment here! I will try to get back to you within a few days.
Shrink or shorten text that doesn't fit its container for popups or other UI elements. · By
Remember Ren'Py loads files in ASCII order - so, if you've got 01_truncate_text.rpy inside a folder, it'll run based on the folder name.
Aka something like game/backend/01_truncate_text.rpy runs AFTER game/accessibility.rpy (so you couldn't use truncate_text inside accessibility.rpy).
I did request a special lib folder for the next version of Ren'Py, but at the moment your best bet is putting external libraries that need to run first inside a folder called something like 01_libraries/ so they run before your other files.
Alright, now I've successfully caused a new problem:
So far, truncate_text runs fine until it actually has to cut something off. Whenever I set ysize or a surrounding fixed to a value smaller than what could contain the full text, it throws the error above. For example:
truncate_text last_phrase text_size 20 ysize 30
Here, last_phrase gets information attached to each save file and is defined on the save screen:
$ last_phrase = FileJson(slot, "last_line", empty="", missing=" ")
While "last_line" is obtained like this:
def the_lastline(d): mylast_line = getattr(store, '_last_raw_what', '',) if not mylast_line: mylast_line = getattr(store, '_last_choice_what', '',) if mylast_line == "ending": line_take = str(len(true_endings))+ _("/14 Rehabilitated") else: line_take = renpy.substitute(renpy.filter_text_tags(mylast_line, allow=[])) line_take = line_take.replace("\n", "") line_take = line_take.replace("\\", "") line_take = "\"" + line_take + "\"" if line_take == "\"\"": line_take = "" d["last_line"] = line_take
I don't really know what's going on here, but I could imagine "_last_raw_what" is the issue (getting dialogue text instead of "normal" text).
Any idea for a workaround to make it compatible with truncate_text?
Actually I think this is a very funny one - do you have a character named re? That's the name I imported the regex library under. I should probably put this in a separate namespace to avoid this kind of issue lol. If that's the case, then you can update `import re` to `import re as regex` and change all the `re.` method calls to `regex.` method calls.