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.
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.
# 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.
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).
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).
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?
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
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.
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
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.
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?)
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?)
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.