Game mod - changing an image

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.
Post Reply
Message
Author
spiker1984
Newbie
Posts: 3
Joined: Mon Jan 01, 2018 11:32 pm
Contact:

Game mod - changing an image

#1 Post by spiker1984 »

Thank you so much in advance.

I am trying to write a mod/conversion for a Ren'py game. The game itself is a dating sim, I believe using the DSE. It's all Hentai-images.
My mod intends to be a "real-photos" mod - I want all the backgrounds, sprites, and images to be real photos of real places, people, etc.

I have so far been successful! I gathered the photos, over-wrote them in the proper folders, and all was well. Sometimes I had to rewrite the .rpy files, for instance to change :
image bg forest = "/images/backgrounds/forest.png"
to
image bg forest = "/images/backgrounds/forest.jpg"

Because of the drawn style, about half the pictures are .pngs. Most of my photos are .jpgs. I've also added a number of .ogv videos to run in place of static images. When it works, it looks awesome.

RIGHT NOW - things work.

MY ISSUE: The developer patches/updates the game regularly, and if I have to edit the .rpy files each time, that's a huge hassle. It also prevents this mod/conversion from running in concert with any other mod that edits the .rpy files (there are a bunch).

WHAT I HAVE TRIED:
  • Translation System- I know that I can make this a "real photos language" translation, and use a separate folder in /tl/realphotos with images that would overwrite the originals, but it doesn't allow me to add .jpg instead of .png, or to add videos instead of static images
  • Mod system: I can add another .rpy file with new image definitions with the new images, but the original .rpy files call the old images. I don't think this works for me?
Thank you for any help.

User avatar
Remix
Eileen-Class Veteran
Posts: 1628
Joined: Tue May 30, 2017 6:10 am
Completed: None... yet (as I'm still looking for an artist)
Projects: An un-named anime based trainer game
Contact:

Re: Game mod - changing an image

#2 Post by Remix »

Maybe missing_image_callback: (untested)

Code: Select all

init python:
    def find_the_rascal( file_to_find ):
        ftf_parts = file_to_find.split('.')
        for ext in ['.png','.jpg','.jpeg']:
            file_to_test = '.'.join( ftf_parts[:-1] ) + ext
            if renpy.loadable( file_to_test ):
                return file_to_test 
        return None

define config.missing_image_callback = find_the_rascal
Not too sure about the videos, perhaps return the video object rather than a filename string could work (tbh, you might have to return Image( file_to_test ) for the images anyway)
Frameworks & Scriptlets:

spiker1984
Newbie
Posts: 3
Joined: Mon Jan 01, 2018 11:32 pm
Contact:

Re: Game mod - changing an image

#3 Post by spiker1984 »

Thanks for the suggestion. This is about one level higher than my non-programmer-brain can figure out.

I think I'm misreading part of that and can't quite figure out what is a variable and what is part of the code.

For instance, I deleted a file called "backgrounds/example1.png" and placed a file called "backgrounds/example1.jpg" in the backgrounds folder.
Then I made a mod with the following text:

Code: Select all

init python:
    def find_the_rascal( "backgrounds/battleground.png" ):
        ftf_parts = file_to_find.split('.')
        for ext in ['.png','.jpg','.jpeg']:
            file_to_test = '.'.join( ftf_parts[:-1] ) + ext
            if renpy.loadable( "backgrounds/battleground.jpg" ):
                return file_to_test 
        return None

define config.missing_image_callback = find_the_rascal
Error'd out - "couldn't find example1.png". Did I not actually run the code?
Thanks...

User avatar
Remix
Eileen-Class Veteran
Posts: 1628
Joined: Tue May 30, 2017 6:10 am
Completed: None... yet (as I'm still looking for an artist)
Projects: An un-named anime based trainer game
Contact:

Re: Game mod - changing an image

#4 Post by Remix »

lol, the code I posted shouldn't need changing for every image... it basically just tells Ren'py what to do if Ren'py cannot find an image (if not found, rip apart the filename, try the same with .png/.jpg instead)

testing it would be done just by showing the image

show expression Image("backgrounds/battleground.jpg", pos=(0.5,0.5)) # if that works, try changing to .png and see if code finds .jpg instead
Frameworks & Scriptlets:

User avatar
Remix
Eileen-Class Veteran
Posts: 1628
Joined: Tue May 30, 2017 6:10 am
Completed: None... yet (as I'm still looking for an artist)
Projects: An un-named anime based trainer game
Contact:

Re: Game mod - changing an image

#5 Post by Remix »

Note: the 'lol' wasn't at you, it was at the thought of rewriting the function for every image
Frameworks & Scriptlets:

spiker1984
Newbie
Posts: 3
Joined: Mon Jan 01, 2018 11:32 pm
Contact:

Re: Game mod - changing an image

#6 Post by spiker1984 »

Oh I see! Thanks. I'll try that.

And don't worry - I think I totally deserve a "lol" from time to time. And I agree I wasn't too thrilled about trying to rewrite a function for every image.
Thanks so much :)

Apa
Regular
Posts: 103
Joined: Fri Dec 23, 2016 2:26 am
Location: NYC
Contact:

Re: Game mod - changing an image

#7 Post by Apa »

spiker1984 wrote: Sat Jan 06, 2018 10:48 am I agree I wasn't too thrilled about trying to rewrite a function for every image.
BTW: There was an example somewhere to auto-define images from a specific folder (recursively, if needed)
Alternatively, you can use same code to generate static image definitions instead of doing it manually on every change. :oops:

Post Reply

Who is online

Users browsing this forum: Google [Bot]