This might be used to make DLC patches that add routes, characters, or other content to a base game, but are distributed or sold separately.
It also might be used to make "mature" game patches that uncensor images and add sex or gore scenes to the game script, while leaving that content out of the base game.
Step 1: Set up the directory for the patch
First, you should create a new folder in your game directory. This is where we will put all of the content we want to include in the patch, but not the base game. Make sure that your game can run smoothly even without anything you put in there, since the patch will be detachable from the game later.
Inside the patch folder, make an RPY file. We will use this file to control how the patch functions. Also, put any images, music, or files that will be patched into the game inside the patch folder. By putting them here, we can make it so these files are included with the patch, and don't take up extra file space in the base game.
Step 2: Make the patch change a persistent variable on game startup, and define patch assets.
Now, we're going to set a persistent variable. First, we put this code in the regular script.rpy, above the start label:
Code: Select all
init -3 python:
persistent.patch_installed = False
init -1 python:
if persistent.patch_installed and not persistent.patch_first_time:
persistent.patch_enabled = True
persistent.patch_first_time = True
elif not persistent.patch_installed:
persistent.patch_first_time = False
persistent.patch_enabled = False
Code: Select all
init -2:
$ persistent.patch_installed = True
To go a step further, the game will then set a variable "persistent.patch_enabled," which will determine if the patch has been turned on/off by the player if you put an option in the settings menu to turn the patch off without leaving the game.
Next, in the patch RPY file, define all of the new assets that will only be used in the patch, and are contained in the folder. Do this the exact same way as you would at the top of script.rpy.
For example, if you want to make a content patch that adds Lucy to the game, the patch RPY file might look something like this:
Code: Select all
### This file can be used to define content in the patch, and enable the persistent variable if the patch exists.
### Initial Variable Setup:
init -2:
$ persistent.patch_installed = True
### Declare characters used in the patched content.
define l = Character("Lucy", who_color="#ffcccc")
### Declare images used in the patched content.
image lucy happy = "patch/images/lucy_happy.png"
image lucy mad = "patch/images/lucy_mad.png"
### Declare music and sounds used in the patched content.
define audio.track2 = "patch/audio/track2.ogg"
define audio.punch = "patch/audio/punch.wav"
Now for the fun part. Throughout your game, you can test the "persistent.patch_enabled" variable to see if the patch is enabled or not. For example:
Code: Select all
if persistent.patch_enabled:
jump patch_scene
Code: Select all
if persistent.patch_enabled:
show uncensored image
else:
show censored image
Code: Select all
if persistent.patch_enabled:
"I film her in the party."
else:
"I f*** her in the p****."
Code: Select all
menu:
"I love Eileen":
jump eileen_romance
"I love Lucy":
jump lucy_romance
"I love both girls" if persistent.patch_enabled:
jump harem_route
You can also place ConditionSwitch on images, if you want the patch to change how certain characters look without altering tons of code. This might be useful for patches that just add cat ears to characters, or swap some images for others. Here's an example:
Code: Select all
image eileen pose = ConditionSwitch(
"persistent.patch_enabled", "patch/images/eileen_pose_cat_ears.png",
"not persistent.patch_enabled", "images/eileen_pose.png"
)
For those who want some added functionality out of the patch, and have some added knowledge of screens and customization, you can do the same thing above with Repy's GUI as you can with the script.
For starters, you can add some text to the main menu in screens.rpy if you like, so the player can rest assured that they installed the patch correctly.
Code: Select all
textbutton _("Start Game") action Start()
textbutton _("Load Game") action ShowMenu("load")
textbutton _("Preferences") action ShowMenu("preferences")
textbutton _("Help") action Help()
textbutton _("Quit") action Quit(confirm=False)
if persistent.patch_enabled:
text "Patch applied!" xalign 0.0 yalign 1.0
Code: Select all
if persistent.patch_installed:
frame:
style_group "pref"
has vbox
label _("Patch")
textbutton _("On") action [SetField(persistent, "patch_enabled", True), SelectedIf(persistent.patch_enabled)]
textbutton _("Off") action [SetField(persistent, "patch_enabled", False), SelectedIf(not persistent.patch_enabled)]
Now that you've programmed your game and told it what to do if the patch is enabled or disabled, it's time to build the game distribution and share it with the world! Hit that button on the Renpy Launcher that says "Build Distributions." If you are prompted to add build information to the end of options.rpy, say "yes."
Now that you're sure you have the build information on the bottom of options.rpy, open it up and take a look. You can modify the archive settings if you like, but the most important part is that you archive the patch folder to a separate file.
Code: Select all
build.archive("Patch", "all")
build.classify('game/patch/**.**', 'Patch')
After you've finished modifying the code, go back to the Renpy Launcher and finish building the distributions. Extract the ZIP file that is created, and you should find that the patch folder is gone, replaced by a Patch.rpa file.
This is your completed game version, already patched! The distribution will run as if the patch was installed as long as the Patch.rpa stays in the game folder. To make the game run without the patched material, simply move or delete the Patch.rpa file. You can also feel free to rename the Patch.rpa file to whatever you like, as long as it remains a RPA file, and is in the correct directory.
A sample game is attached below, to show an example of how this works. When the patch is installed and enabled, a different ending will occur. Let me know if you have questions.