To create an easy modular Gallery mod for a RenPy game without touching the original files, you can follow these steps:
-
Create a new folder in your game directory called "mod_gallery" or any name you prefer.
-
Inside "mod_gallery," create a new text file and save it with the extension ".rpy," such as "mod_gallery.rpy"
-
Open "mod_gallery.rpy" using a text editor, and add the following code to define the gallery screen:
init python:
# Create a list to store the gallery images
mod_gallery_images = []
def mod_gallery_add_image(image, unlocked=False):
# Function to add images to the gallery
mod_gallery_images.append((image, unlocked))
screen mod_gallery:
tag menu
# Gallery background
window:
style "gm_root"
# Gallery title
label _("Gallery"):
style "gm_title"
# Grid for displaying images
grid 3 3:
style "gm_grid"
for image, unlocked in mod_gallery_images:
# If the image is unlocked, display it as a button
if unlocked:
button:
background Image(image)
action [Show("mod_image_viewer", image=image), Play("sound", "click.ogg")]
# If the image is locked, display it as a locked image
else:
add "locked_image"
# Return button
textbutton _("Return") action Return() style "gm_button"
screen mod_image_viewer(image):
tag menu
add image
# Return button
textbutton _("Return") action Return() style "iv_button"
-
Add the images you want to include in your gallery to the "mod_gallery" folder.
-
In the "mod_gallery.rpy" file, add the images to the gallery using the mod_gallery_add_image function. For example:
init -1 python:
mod_gallery_add_image("mod_gallery/image1.jpg", unlocked=True)
mod_gallery_add_image("mod_gallery/image2.jpg", unlocked=True)
mod_gallery_add_image("mod_gallery/image3.jpg", unlocked=False)
- Modify your game's main menu screen to include a new button that opens the gallery screen. To do this, create a new ".rpy" file in the "mod_gallery" folder (e.g., "mod_gallery_menu.rpy") and add the following code: