Image in folder not found

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
nuby
Newbie
Posts: 5
Joined: Thu Jun 29, 2017 5:12 pm
Contact:

Image in folder not found

#1 Post by nuby »

I have ren'py set to show the file mc_happy as mc h right before the first line of dialogue. However, no matter what I try, I end up with "could not find file 'mc_happy.png". I know it's in the folder. I have tried basically everything and the closest i've gotten is having no character pop up at all while having the dialogue going.

Code: Select all

# The script of the game goes in this file.
# game resolution - 1280x720

# Declare characters used by this game. The color argument colorizes the
# name of the character.

define e = Character("Eileen") # delete later
define mc = Character("Me")

image mc h = "mc_happy.png"

# The game starts here.

label start:

    scene bg room

    show mc h

    # These display lines of dialogue.

    mc "Here it was."
    
    mc "My first day at my new school."
    
    # This ends the game.

    return
I know it's pretty generic and there's not much but this is my first project so I'd really appreciate the help.

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

Re: Image in folder not found

#2 Post by Imperf3kt »

Do you have hide file extensions on? It is default in Windows. You might see mc_happy.png but could have mc_happy.png.png
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

User avatar
chocoberrie
Veteran
Posts: 254
Joined: Wed Jun 19, 2013 10:34 pm
Projects: Marshmallow Days
Contact:

Re: Image in folder not found

#3 Post by chocoberrie »

Two things:

1) Your image definitions aren't in an init block.
2) Did you check the file paths for the images?

Here is an example:

Code: Select all

init:   
    image bg street = "BGs/bg_street.jpg"
    image bg school hall = "BGs/school_hall.jpg"
    image bg school grounds = "BGs/school_grounds.jpg"

label start:
Each of these images is in a folder called "BGs," which is within the folder called "game" (the default folder where all of the Ren'Py files are).

nuby
Newbie
Posts: 5
Joined: Thu Jun 29, 2017 5:12 pm
Contact:

Re: Image in folder not found

#4 Post by nuby »

chocoberrie wrote:Two things:

1) Your image definitions aren't in an init block.
2) Did you check the file paths for the images?

Here is an example:

Code: Select all

init:   
    image bg street = "BGs/bg_street.jpg"
    image bg school hall = "BGs/school_hall.jpg"
    image bg school grounds = "BGs/school_grounds.jpg"

label start:
Each of these images is in a folder called "BGs," which is within the folder called "game" (the default folder where all of the Ren'Py files are).
So would the correct way to do this be..

Code: Select all

init:
    image mc h = "images/mc_happy.png"

# The game starts here.

label start:
? This still has the same result as before. Also, I do not see the BGs folder in my game folder. Should I manually add this? Also, I did not manually add .png to the end, I assume Windows did and then hid the extension?

User avatar
chocoberrie
Veteran
Posts: 254
Joined: Wed Jun 19, 2013 10:34 pm
Projects: Marshmallow Days
Contact:

Re: Image in folder not found

#5 Post by chocoberrie »

No no, I mean if your images are in a subfolder, make sure to include the subfolder in the image definition. The "BGs" folder is an example, that is what I did for my images. I made a folder called "BGs" within the "game" folder. In the "BGs" folder, I put the image files I defined in the example code. The file path is indicated for each image, as well as the file extension.

Because the images are in the "BGs" folder, I have:
image [image tag here] = "folder name here/file name.extension"
(*Note: Don't include the brackets shown above.)

The reason why I have subfolders is because it's easier to organize images. Putting them all in the "game" folder with the script files makes organization difficult.

See the screenshots below:
Attachments
2.png
1.PNG
1.PNG (10.49 KiB) Viewed 5923 times
Last edited by chocoberrie on Thu Jun 29, 2017 7:39 pm, edited 1 time in total.

nuby
Newbie
Posts: 5
Joined: Thu Jun 29, 2017 5:12 pm
Contact:

Re: Image in folder not found

#6 Post by nuby »

chocoberrie wrote:No no, I mean if your images are in a subfolder, make sure to include the subfolder in the image definition. The "BGs" folder is an example, that is what I did for my images. I made a folder called "BGs" within the "game" folder. In the "BGs" folder, I put the image files I defined in the example code. The file path is indicated for each image, as well as the file extension.

Because the images are in the "BGs" folder, I have:
image [image tag here] = folder name here/file name.extension
(*Note: Don't include the brackets shown above.)

The reason why I have subfolders is because it's easier to organize images. Putting them all in the "game" folder with the script files makes organization difficult.

See the screenshots below:
Oh! My mistake. I moved the sprites from images to my own Sprites folder and changed the code accordingly

Code: Select all

init:
    image mc h = Sprites/mc_happy.png

# The game starts here.

label start:
I'm afraid now instead of "image not found" I'm getting

Code: Select all

I'm sorry, but an uncaught exception occurred.

While running game code:
  File "game/script.rpy", line 20, in script
    image mc h = Sprites/mc_happy.png
  File "game/script.rpy", line 20, in <module>
    image mc h = Sprites/mc_happy.png
NameError: name 'Sprites' is not defined
This seems like a simple enough fix but I regret to say I'm at a loss again. Hopefully when this is done it will be a one time problem, so I apologize if I'm wasting your time.

User avatar
chocoberrie
Veteran
Posts: 254
Joined: Wed Jun 19, 2013 10:34 pm
Projects: Marshmallow Days
Contact:

Re: Image in folder not found

#7 Post by chocoberrie »

You need quotation marks! Sorry, it was my mistake; I did not add those.

Try this:

Code: Select all

init:
    image mc h = "Sprites/mc_happy.png"

# The game starts here.

label start:

nuby
Newbie
Posts: 5
Joined: Thu Jun 29, 2017 5:12 pm
Contact:

Re: Image in folder not found

#8 Post by nuby »

Back to "can't find" w/ quotes.. darn. What should I try now?

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

Re: Image in folder not found

#9 Post by Imperf3kt »

Go back to the very basics.
Renpy can auto define your images.
If you have show "bob.png" and bob.png is in the images folder, it will work.

If you wish to use tags, define them before the start label in your script or place them in an init block as shown by chocoberrie.

Code: Select all

image bob happy = "bob_happy.png"

label start:
    show bob happy
You must have an image called "bob_happy.png" in the images folder for this to work.
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

nuby
Newbie
Posts: 5
Joined: Thu Jun 29, 2017 5:12 pm
Contact:

Re: Image in folder not found

#10 Post by nuby »

I've solved the problem! I don't really know what the problem was OR how I fixed it.. but thank you guys for your help! :)

User avatar
trooper6
Lemma-Class Veteran
Posts: 3712
Joined: Sat Jul 09, 2011 10:33 pm
Projects: A Close Shave
Location: Medford, MA
Contact:

Re: Image in folder not found

#11 Post by trooper6 »

image definitions don't need to be in an init block.
A Close Shave:
*Last Thing Done (Aug 17): Finished coding emotions and camera for 4/10 main labels.
*Currently Doing: Coding of emotions and camera for the labels--On 5/10
*First Next thing to do: Code in all CG and special animation stuff
*Next Next thing to do: Set up film animation
*Other Thing to Do: Do SFX and Score (maybe think about eye blinks?)
Check out My Clock Cookbook Recipe: http://lemmasoft.renai.us/forums/viewto ... 51&t=21978

User avatar
chocoberrie
Veteran
Posts: 254
Joined: Wed Jun 19, 2013 10:34 pm
Projects: Marshmallow Days
Contact:

Re: Image in folder not found

#12 Post by chocoberrie »

trooper6 wrote:image definitions don't need to be in an init block.
Oh! I didn't know that. Thanks for the clarification; I'll check the documentation.

User avatar
trooper6
Lemma-Class Veteran
Posts: 3712
Joined: Sat Jul 09, 2011 10:33 pm
Projects: A Close Shave
Location: Medford, MA
Contact:

Re: Image in folder not found

#13 Post by trooper6 »

image definitions, character definitions, variable definitions using define and default: none of those need to be in init blocks.
A Close Shave:
*Last Thing Done (Aug 17): Finished coding emotions and camera for 4/10 main labels.
*Currently Doing: Coding of emotions and camera for the labels--On 5/10
*First Next thing to do: Code in all CG and special animation stuff
*Next Next thing to do: Set up film animation
*Other Thing to Do: Do SFX and Score (maybe think about eye blinks?)
Check out My Clock Cookbook Recipe: http://lemmasoft.renai.us/forums/viewto ... 51&t=21978

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

Re: Image in folder not found

#14 Post by Imperf3kt »

trooper6 wrote:image definitions, character definitions, variable definitions using define and default: none of those need to be in init blocks.
But they do need to be outside of any labels. Keep that part in mind.

One exception though. If you are using legacy mode and you use Leon's CG gallery code, you do infact need to duplicate your image definitions inside an init block otherwise it won't work.
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

Post Reply

Who is online

Users browsing this forum: No registered users