Is it possible to load an image from a path with Ren'py?

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
Shiron
Newbie
Posts: 18
Joined: Fri Sep 28, 2018 8:10 am
Contact:

Is it possible to load an image from a path with Ren'py?

#1 Post by Shiron »

Hi, I'm thinking of reprogramming my game to ren'py, because my old engine has stopped developing more than 10 years ago (and it's not much designed for VN anyway), but I have noticed that you can't really load an image from a path, here.

I'm giving my players an option to customize their characters by loading a directory with their own pictures and they can even load some other txt overrides allowing them to change certain behaviour of targeted characters. Is there some hidden way to do that with this engine? Thank you for the answer.

Shiron

User avatar
Per K Grok
Miko-Class Veteran
Posts: 882
Joined: Fri May 18, 2018 1:02 am
Completed: the Ghost Pilot, Sea of Lost Ships, Bubbles and the Pterodactyls, Defenders of Adacan Part 1-3, the Phantom Flyer
itch: per-k-grok
Location: Sverige
Contact:

Re: Is it possible to load an image from a path with Ren'py?

#2 Post by Per K Grok »

Shiron wrote: Fri Sep 28, 2018 8:27 am Hi, I'm thinking of reprogramming my game to ren'py, because my old engine has stopped developing more than 10 years ago (and it's not much designed for VN anyway), but I have noticed that you can't really load an image from a path, here.

I'm giving my players an option to customize their characters by loading a directory with their own pictures and they can even load some other txt overrides allowing them to change certain behaviour of targeted characters. Is there some hidden way to do that with this engine? Thank you for the answer.

Shiron
I'm not quit sure I understand exactly what it is you want to be able to do.

In the basic setup you have an 'images' folder in your game folder. The images that are to be used in the game should be placed there. Images in the 'images' folder will be automatically loaded in the game using the name of the file in lower case and without the file extension, but you could also load them using a statement giving the image a new name.

image myPix1="theActualImageFile.png"

The 'images' folder is the base folder for this. But you could place a sub-folder in it and load an image from that like this.

image myPix2= "sub/theActualImageFile.png"

or you could place the image outside the 'image' folder and use a relative path to direct the program to it.

image myPix3="../usersImages/theImage.png"

The program will now look for the image in a 'usersImages' folder that is a sub-folder to the 'game' folder.

I am however unclear on in what way that would be useful to do.

When you build a distribution of your game your images file will be openly included in that if you use the standard build set up. The player can go there and replace the images provided with the game for their own images (using the same name as the replaced image) if they want to do that. Or add more images there. Not sure on how you easily could detect new additional images and use them in the game.


For opening and reading text files you would use python. The link below should get you started on that.

https://www.pythonforbeginners.com/file ... -in-python.

Shiron
Newbie
Posts: 18
Joined: Fri Sep 28, 2018 8:10 am
Contact:

Re: Is it possible to load an image from a path with Ren'py?

#3 Post by Shiron »

Per K Grok wrote: Sat Sep 29, 2018 2:14 am I'm not quit sure I understand exactly what it is you want to be able to do.

In the basic setup you have an 'images' folder in your game folder. The images that are to be used in the game should be placed there. Images in the 'images' folder will be automatically loaded in the game using the name of the file in lower case and without the file extension, but you could also load them using a statement giving the image a new name.

image myPix1="theActualImageFile.png"

The 'images' folder is the base folder for this. But you could place a sub-folder in it and load an image from that like this.

image myPix2= "sub/theActualImageFile.png"

or you could place the image outside the 'image' folder and use a relative path to direct the program to it.

image myPix3="../usersImages/theImage.png"

The program will now look for the image in a 'usersImages' folder that is a sub-folder to the 'game' folder.

I am however unclear on in what way that would be useful to do.

When you build a distribution of your game your images file will be openly included in that if you use the standard build set up. The player can go there and replace the images provided with the game for their own images (using the same name as the replaced image) if they want to do that. Or add more images there. Not sure on how you easily could detect new additional images and use them in the game.


For opening and reading text files you would use python. The link below should get you started on that.

https://www.pythonforbeginners.com/file ... -in-python.
Thank you so much, that is basically the answer I was looking for. It seems I'll have to do some changes in the current game mechanism, but I can see a way around with this engine...

See you again later. :)

User avatar
Imperf3kt
Lemma-Class Veteran
Posts: 3791
Joined: Mon Dec 14, 2015 5:05 am
itch: Imperf3kt
Location: Your monitor
Contact:

Re: Is it possible to load an image from a path with Ren'py?

#4 Post by Imperf3kt »

There was a post on the forums about 2 or 3 years ago, asking how to let a player add their own music to a game(without pre-defining it). IIRC, it had a successful answer, but I cannot find it through searches. Maybe the same can be applied to images?
Warning: May contain trace amounts of gratuitous plot.
pro·gram·mer (noun) An organism capable of converting caffeine into code.

Current project: GGD Mentor

Twitter

Shiron
Newbie
Posts: 18
Joined: Fri Sep 28, 2018 8:10 am
Contact:

Re: Is it possible to load an image from a path with Ren'py?

#5 Post by Shiron »

Imperf3kt wrote: Sat Sep 29, 2018 5:54 am There was a post on the forums about 2 or 3 years ago, asking how to let a player add their own music to a game(without pre-defining it). IIRC, it had a successful answer, but I cannot find it through searches. Maybe the same can be applied to images?
I'm working on it and until now it has run just fine.

For the time being, I have created my own "GUI" directory, where any player can basically change the layout of the game, so they can fit it more to the chosen characters style...

But I've noticed, that at least gui\button\choice_hover_background.png and gui\button\choice_idle_background.png can be loaded ONLY from the original directory. The path seems to be loaded from some "common" list and no .rpy file actually allows you to change it.

In the screens.rpy file it is called through some properties gui.button_properties("choice_button") line, but you can't set this "choice_button" image path anywhere. Do you have an idea about it, or is it actually problem of the engine itself?

Post Reply

Who is online

Users browsing this forum: Alex