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.
It looks like label munging is broken if the file contains any weird characters. For example, in part4-something.rpy, the following error happens:
On line 44 of part4-something.rpy: expected ':' not found.
label _m1_part4-something__init_variables:
Ren'Py Version: Ren'Py 6.8.1a
Something like this should fix it, but I can't test it at the moment because my whole renpy installation broke down because of PyDev being too smart and recompiling stuff (goes in parser.py):
# this contains a translation table used to get rid of characters not
# allowed in labels
munge_trans = string.maketrans(" -","__")
def munge_filename(fn):
# The prefix that's used when __ is found in the file.
rv = os.path.basename(fn)
rv = os.path.splitext(rv)[0]
rv = rv.translate(munge_trans)
return "_m1_" + rv + "__"
Update: Added import, use qualified name in maketrans call
Seems to me the problem here is simply that your label contains a "-" character, and that's not allowed. This seems to fall into the category of "Doctor, it hurts when I do this" / "Then don't do that" solutions.
Well, we don't explicitly disallow it. So I will be fixing this in the next version of Ren'Py. I'll probably use a whitelist and escape all non-whitelist characters, rather than a blacklist on '-' and ' '.
Supporting creators since 2004 (When was the last time you backed up your game?)
PyTom wrote:Well, we don't explicitly disallow it. So I will be fixing this in the next version of Ren'Py. I'll probably use a whitelist and escape all non-whitelist characters, rather than a blacklist on '-' and ' '.
Cool, that might also solve the case when there are two file names called the same, but placed in different directories (personally, I haven't run into this, but the code looks like it uses just the filename and not the path relative to the game directory). Then again, I don't think that too many games use this, so it's probably not worth the effort. Maybe it could be used by JQuartz's menu editor, instead of using a manual prefix. Does munging work for variable and function names too?