TrooperJustinHare
New Member
- Aug 11, 2025
- 6
- 1
Good day! I'm making a mod for a RenPy 7.4.11 game (and I'll answer beforehand that this game has Steam workshop support, and the author allows creating any modifications for his game). The mod itself is a tool to auto initialize resources of the mod (i.e. images, audio, etc) while loading the game (yes, built-in RenPy autoinit won't do.).
Long story short, I just discovered that if, instead of running a script to search for and initialize files, you create a file with the file paths already set with the help of a script, the game will load much faster than with the first autoinit option. But there is a problem: when creating this .rpy file in the script, in order for RenPy to compile it, you need to restart the game.
I did some digging in the RenPy documentation and found that RenPy supports the CLI and can pass the "compile" argument to it, but this won't work since it's designed for a folder (like a game folder), not just a single file, and also create a bunch of junk files inside of it after compiling.
So, is there any way to compile a single .rpy file?
Long story short, I just discovered that if, instead of running a script to search for and initialize files, you create a file with the file paths already set with the help of a script, the game will load much faster than with the first autoinit option. But there is a problem: when creating this .rpy file in the script, in order for RenPy to compile it, you need to restart the game.
Python:
def process_files(self):
"""
Processes the mod files.
If the write_into_file value is True, it writes the mod's resources to a separate file rather than initializing them. To further initialize the mod's resources from the file, you need to restart the game.
"""
if self.write_into_file:
with builtins.open(self.modPath + "/assets.rpy", "w") as log_file:
log_file.write("init python:\n ")
for type, file_name, file in self.modFiles:
if type == "sound":
log_file.write("%s = \"%s\"\n " % (file_name, file))
elif type == "image":
log_file.write("renpy.image(\"%s\", \"%s\")\n " % (file_name, file))
if type == "sprite":
log_file.write("renpy.image(\"%s\", %s)\n " % (file_name, file))
else:
for type, file_name, file in self.modFiles:
if type == "sound":
globals()[file_name] = file
elif type == "image":
renpy.image(file_name, file)
if type == "sprite":
renpy.image(file_name, eval(file))
So, is there any way to compile a single .rpy file?