$ renpy.show and image directory

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.
Message
Author
User avatar
Remix
Eileen-Class Veteran
Posts: 1315
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: $ renpy.show and image directory

#16 Post by Remix » Wed Aug 28, 2019 7:03 pm

You could (for initial question) just change the way Ren'Py handles automatic image definition...

Tell it to use folder names as tags or attributes, include underscores as separators and skip the folders 'images' and 'characters'...

Code: Select all

define config.automatic_images = [' ', '_', '/']
define config.automatic_images_strip = ['images','characters']

# Presuming you had "images/characters/ch1/home/1b.png" it would create "ch1 home 1b"

$ renpy.show("ch1 home 1"+persistent.filter)
Mad Scientist Todo List:
  • Finish Improved Event Handler
  • Implement DragonBones animation as a Creator Defined Container
  • Develop Cartoon Speech Bubble dialogue
  • Finish Bitmask collision and rebound vector system
  • Develop time based building mechanic
  • Others
  • *Find a superb artist and actually write a game*

User avatar
hell_oh_world
Regular
Posts: 175
Joined: Fri Jul 12, 2019 5:21 am
Projects: Pathfinding
Organization: NILA
Contact:

Re: $ renpy.show and image directory

#17 Post by hell_oh_world » Wed Aug 28, 2019 7:11 pm

numaej wrote:
Wed Aug 28, 2019 7:01 pm
Simple renpy animation by combining two images.

Code: Select all

image animationa:
    "ch01home1.jpg"
    0.3
    "ch01home2.jpg"
    0.3
I have no idea how to make $ renpy.show command show it.
I tried it with normal quotes and it did work.

$ renpy.show("animationa")

User avatar
hell_oh_world
Regular
Posts: 175
Joined: Fri Jul 12, 2019 5:21 am
Projects: Pathfinding
Organization: NILA
Contact:

Re: $ renpy.show and image directory

#18 Post by hell_oh_world » Wed Aug 28, 2019 7:14 pm

Remix wrote:
Wed Aug 28, 2019 7:03 pm
You could (for initial question) just change the way Ren'Py handles automatic image definition...

Tell it to use folder names as tags or attributes, include underscores as separators and skip the folders 'images' and 'characters'...

Code: Select all

define config.automatic_images = [' ', '_', '/']
define config.automatic_images_strip = ['images','characters']

# Presuming you had "images/characters/ch1/home/1b.png" it would create "ch1 home 1b"

$ renpy.show("ch1 home 1"+persistent.filter)
But he wants to do the calling of images with just a number to minimize the effort of typing long names of images. Only with one word I guess. You might have a solution for it?

numaej
Newbie
Posts: 22
Joined: Fri Dec 21, 2018 9:24 am
Contact:

Re: $ renpy.show and image directory

#19 Post by numaej » Wed Aug 28, 2019 7:20 pm

I think I need quotes, because of the persistent.
When I have them renpy shows me this error:
"Can't find "ch1home1.jpg""

Without quotes it says that "name animation is not defined", and the persistent is the most important here as it stands for a feature of my game. For example lets assume that persistent filter 'a' stands for day renders while 'b' stands for night. Player choose what set they want at the beginning of the game and they'll have that kind of images displayed while playing. With this being said, I can't just show them an random animation, I prepared myself and created two different sets of renders for each filter. Now, all I'm looking for is to show players the animation with the filter setup they are interested in.

@Remix

Sadly, it doesn't work... Although, I really wish it would, because it's probably what I'm looking for.

my subfolders are directly in images, so its:
images/ch1/home/1.jpg

User avatar
hell_oh_world
Regular
Posts: 175
Joined: Fri Jul 12, 2019 5:21 am
Projects: Pathfinding
Organization: NILA
Contact:

Re: $ renpy.show and image directory

#20 Post by hell_oh_world » Wed Aug 28, 2019 7:22 pm

numaej wrote:
Wed Aug 28, 2019 7:20 pm
I think I need quotes, because of the persistent.
When I have them renpy shows me this error:
"Can't find "ch1home1.jpg""

Without quotes it says that "name animation is not defined", and the persistent is the most important here as it stands for a feature of my game. For example lets assume that persistent filter 'a' stands for day renders while 'b' stands for night. Player choose what set they want at the beginning of the game and they'll have that kind of images displayed while playing. With this being said, I can't just show them an random animation, I prepared myself and created two different sets of renders for each filter. Now, all I'm looking for is to show the players the set they are interested in.

@Remix

Sadly, it doesn't work... Although, I really wish it would, because it's probably what I'm looking for.

my subfolders are directly in images, so its:
images/ch1/home/1.jpg
Why its not working? You better show him how you put those codes of him on to your game so that he could give you the right instructions.

User avatar
hell_oh_world
Regular
Posts: 175
Joined: Fri Jul 12, 2019 5:21 am
Projects: Pathfinding
Organization: NILA
Contact:

Re: $ renpy.show and image directory

#21 Post by hell_oh_world » Wed Aug 28, 2019 7:24 pm

numaej wrote:
Wed Aug 28, 2019 7:20 pm
I think I need quotes, because of the persistent.
When I have them renpy shows me this error:
"Can't find "ch1home1.jpg""

Without quotes it says that "name animation is not defined", and the persistent is the most important here as it stands for a feature of my game. For example lets assume that persistent filter 'a' stands for day renders while 'b' stands for night. Player choose what set they want at the beginning of the game and they'll have that kind of images displayed while playing. With this being said, I can't just show them an random animation, I prepared myself and created two different sets of renders for each filter. Now, all I'm looking for is to show players the animation with the filter setup they are interested in.

@Remix

Sadly, it doesn't work... Although, I really wish it would, because it's probably what I'm looking for.

my subfolders are directly in images, so its:
images/ch1/home/1.jpg
Try it like this:

Code: Select all

define config.automatic_images = [' ', '_', '/']
define config.automatic_images_strip = ['images']

label start:
	$ renpy.show("ch1 home 1"+persistent.filter)

numaej
Newbie
Posts: 22
Joined: Fri Dec 21, 2018 9:24 am
Contact:

Re: $ renpy.show and image directory

#22 Post by numaej » Wed Aug 28, 2019 7:29 pm

I've put this code on the top of the script:

Code: Select all

define config.automatic_images = [' ', '_', '/']
define config.automatic_images_strip = ['images']
Without 'characters' because I don't have a folder named like this.

Then I tried

Code: Select all

$ renpy.show("ch1 intro 1"+persistent.filter)
since I didn't change the name their yet

All I got back was the shadow of that chick with the name 'ch1 intro 1' on it.
If this would work, I'd be in heaven, trust me.

User avatar
hell_oh_world
Regular
Posts: 175
Joined: Fri Jul 12, 2019 5:21 am
Projects: Pathfinding
Organization: NILA
Contact:

Re: $ renpy.show and image directory

#23 Post by hell_oh_world » Wed Aug 28, 2019 7:41 pm

numaej wrote:
Wed Aug 28, 2019 7:29 pm
I've put this code on the top of the script:

Code: Select all

define config.automatic_images = [' ', '_', '/']
define config.automatic_images_strip = ['images']
Without 'characters' because I don't have a folder named like this.

Then I tried

Code: Select all

$ renpy.show("ch1 intro 1"+persistent.filter)
since I didn't change the name their yet

All I got back was the shadow of that chick with the name 'ch1 intro 1' on it.
If this would work, I'd be in heaven, trust me.
It's just showing a regular text if you're seeing that. Means that the image cannot be found I guess.

numaej
Newbie
Posts: 22
Joined: Fri Dec 21, 2018 9:24 am
Contact:

Re: $ renpy.show and image directory

#24 Post by numaej » Wed Aug 28, 2019 8:03 pm

Indeed, that's why I'm saying that the code doesn't work for me... I don't know where's the problem though... and I have also no idea how to fix the animation.

I'll be really grateful if someone would be able to help me out here.

User avatar
Remix
Eileen-Class Veteran
Posts: 1315
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: $ renpy.show and image directory

#25 Post by Remix » Wed Aug 28, 2019 8:26 pm

with the name 'ch1 intro 1' on it

which implies that persistent.filter is "" at that point and that there is no image that created that reference ... have you checked the folder ch1/intro/ (NOT ./home/) for images named just 1 and made sure there is only one (not a png and a jpg)

I would advise a simple test:
1) Use the code
2) Put an image called 1.png in the ch1 folder
3) Add a line ` show ch1 1 `
4) Move the image to the ch1/intro folder
5) Amend line to ` show ch1 intro 1 `
Mad Scientist Todo List:
  • Finish Improved Event Handler
  • Implement DragonBones animation as a Creator Defined Container
  • Develop Cartoon Speech Bubble dialogue
  • Finish Bitmask collision and rebound vector system
  • Develop time based building mechanic
  • Others
  • *Find a superb artist and actually write a game*

drKlauz
Regular
Posts: 166
Joined: Mon Oct 12, 2015 3:04 pm
Contact:

Re: $ renpy.show and image directory

#26 Post by drKlauz » Thu Aug 29, 2019 7:59 am

Code i posted walk thru all images in all folders inside 'game/images' folder and register them. Converting file path into image name, yes, removing need to hardcode file extension.
For example 'game/images/characters/bob/side_images/angry.png' will be registered as 'bob side_images angry'.

How it doesn't work for you, any error, no images get registered, something else? I'm working on game using this code right now, so i kinda wonder what may go wrong.

User avatar
Remix
Eileen-Class Veteran
Posts: 1315
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: $ renpy.show and image directory

#27 Post by Remix » Thu Aug 29, 2019 1:26 pm

Code: Select all

define config.automatic_images = [' ', '_', '/']
define config.automatic_images_strip = ['images']

label start:

    show expression Text(" - ".join(
        [k for k in renpy.list_images() if not k.startswith('gui')]
        ), size=14) at top 

    "..."
Will run the automatic bit and then tell you all the image references that Ren'Py knows about (excluding gui stuff)
If your image is not listed there, you either have duplicates or naming issues.
Mad Scientist Todo List:
  • Finish Improved Event Handler
  • Implement DragonBones animation as a Creator Defined Container
  • Develop Cartoon Speech Bubble dialogue
  • Finish Bitmask collision and rebound vector system
  • Develop time based building mechanic
  • Others
  • *Find a superb artist and actually write a game*

numaej
Newbie
Posts: 22
Joined: Fri Dec 21, 2018 9:24 am
Contact:

Re: $ renpy.show and image directory

#28 Post by numaej » Fri Aug 30, 2019 2:48 pm

Honestly, I did everything the way it supposed to be done, it didn't work and trust me, I tried few different combinations, well... it's bad for me, but screw it, I can't let myself sit and wonder for the whole day why simple code is not working. So, I changed the names and everything seems working.

For the future generations: if you want to use renpy animation option, images you'll use must be placed directly in the main 'images' folder

Now, I ran into another weird problem... Changing the names seemed to solve to issue with displaying images. Renpy finds them easily now but... Well, but if I want renpy to show again an image that was already shown it doesn't do it. There's no error, though. It just ignores the command. What the hell?

Anyone?
My God, it's so annoying that such simple stuff makes me struggle so much.

User avatar
hell_oh_world
Regular
Posts: 175
Joined: Fri Jul 12, 2019 5:21 am
Projects: Pathfinding
Organization: NILA
Contact:

Re: $ renpy.show and image directory

#29 Post by hell_oh_world » Fri Aug 30, 2019 4:06 pm

numaej wrote:
Fri Aug 30, 2019 2:48 pm
Honestly, I did everything the way it supposed to be done, it didn't work and trust me, I tried few different combinations, well... it's bad for me, but screw it, I can't let myself sit and wonder for the whole day why simple code is not working. So, I changed the names and everything seems working.

For the future generations: if you want to use renpy animation option, images you'll use must be placed directly in the main 'images' folder

Now, I ran into another weird problem... Changing the names seemed to solve to issue with displaying images. Renpy finds them easily now but... Well, but if I want renpy to show again an image that was already shown it doesn't do it. There's no error, though. It just ignores the command. What the hell?

Anyone?
My God, it's so annoying that such simple stuff makes me struggle so much.
Declaring images requires tag and an optional attribute. You can read more of it in here.

https://www.renpy.org/doc/html/displayi ... html#image

Code: Select all

 An image name consists of one or more names, separated by spaces. The first component of the image name is called the image tag. The second and later components of the name are the image attributes.

For example, take the image name mary beach night happy. The image tag is mary, while the image attributes are beach, night, and happy.

So if you declared an image like this

Code: Select all

image ch1 home 1 ....
image ch1 home 2 ....
ch1 is the image tag and home 1 and home 2 are the images' attributes.

In renpy, images declared with the same tag supersedes the other.
If you will call this two images..

Code: Select all


show ch1 home 1

show ch1 home 2

Only one image will appear on the example above because they're of the same tag. Technically, they replace each other each time they are called. TLDR only one image with the same tag can be shown at the same time.

Lucky for you, you can override this through the use of "as" property.

Code: Select all


# Show an image on the right side of the screen.
show mary night happy at right
##$ renpy.show("mary...,)

# Show the same image twice.
show mary night sad as mary2 at left
## $ renpy.show("mary..., tag="mary2")

So, the reason why your images replace each other maybe because they are of the same tag. Using as will solve the problem. Heres the doc about it.

https://www.renpy.org/doc/html/displayi ... -statement

numaej
Newbie
Posts: 22
Joined: Fri Dec 21, 2018 9:24 am
Contact:

Re: $ renpy.show and image directory

#30 Post by numaej » Fri Aug 30, 2019 4:46 pm

I'm actually using this command to display images, because it's the only way to show image with the filter which the player will chose.

Code: Select all

$ renpy.show("ch1intro1"+persistent.filter)
I don't use 'image x' or basic 'show' command at all.
I updated all of the names, so now they are all unique to not make renpy confused.
As I also mentioned, all my images are flat renders - which means, that there's no specif actions on them, one replaces the previous one, and it works just fine. The problem occurs when I have a dialog, and I want to jump between two - the same - renders, it simply doesn't jump back to the previous render, feels like renpy is just ignoring the command, cause there's no error message at all.

for example:

Code: Select all

$ renpy.show("ch1intro1"+persistent.filter)
a "Hi!"
$ renpy.show("ch1intro2"+persistent.filter)
b "Hi! How are you?"

### and from this moment renpy choose to ignore my comand to show the ch1intro1 image again. Instead, ch1intro2 is displayed all the time.

$ renpy.show("ch1intro1"+persistent.filter)
a "Good. How about you?"
$ renpy.show("ch1intro2"+persistent.filter)
b "Great!"

### action moves on, I'm jumping to the next render, renpy does it without any problems

$ renpy.show("ch1intro3"+persistent.filter)
a "Awesome!"
b "Oh, I wanted to tell you... 

### now I want renpy to display the ch1intro2 again, but as well as with ch1intro1 renpy somehow chooses to ignore my comand and displays ch1intro3 all the time

$ renpy.show("ch1intro2"+persistent.filter)
b "Renpy pisses me off, because it's not listening to me!
Hopefully, this will make my problem more clear for you guys.

Post Reply

Who is online

Users browsing this forum: Google [Bot], Imperf3kt