Hey, define wordcounter_uncounted = ["ic"] was very useful for me after installing Caption Tool for Ren’Py (https://npckc.itch.io/caption-tool-for-renpy) to exclude its word count automatically (or any other alt style accessibillity narrator really)
I got another request for you, which may be trickier to implement: excluding words surrounded by certain text tags, in particular {alt}{/alt} which I added, following O2A2 rules, for better self-voicing, but without counting actual extra words!
Example:
mc "...{alt}stays silent{/alt}"
It would also help me in the redundant text that I mentioned in my other comment on choices: instead of playing with string variables to get the true unique word count I need, I would simply write every line separately. Then, I would surround the sequence of words I manually recognized as redundant with {no_word_count} (or just {no_count} if “no_word_count” is too long, best is to let user customize the tag string). You’d need to define a custom tag so Renpy doesn’t complain about tag not existing though:
init python:
def no_word_count_tag(tag, argument, contents):
return contents
config.custom_text_tags["no_word_count"] = no_word_count_tag
Example:
menu:
"Yes":
"{no_word_count}Yes{/no_word_count}"
"No":
"{no_word_count}No{/no_word_count}"
It’s not only useful for choices with redundant text between the displayed choice and the following sentence, but also general lines in different branches that share many common words. I normally use string interpolation to change just a few words, but it has two drawbacks:
- harder to localize
- Renpy skip will consider a line as “seen” even if user has not seen this particular variant (injected string variable having a different value than before)
Example:
if flag:
"OK, I understand"
else:
"{no_word_count}OK, I understand{/no_word_count}, but let's go anyway"
I realize this is probably only useful in O2A2 because writers won’t be super picky about word count in any other context… So if it’s too complicated, you may just ignore this.
I also have my own script to clean up text and copy it to Google Doc to count only relevant words, so I could also write my own REGEX for that…
EDIT: I got away by using extend:
mc "I want to be {nw}"
if goal_free:
extend "free."
else:
extend "loved."
but I realized that {nw} (and {w}, and in fact any tags separated from words by a space like {i} word {/i} are counted as extra words!
Looks like I’ll have to use my custom regex preprocessor…
The trick is to attach the tag to a word (no space between), and add a space later.













































