[SOLVED] Using Images in Show and Scene statements without declaring them in Init.

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
Jg119
Newbie
Posts: 8
Joined: Tue Jan 09, 2018 7:29 am
Contact:

[SOLVED] Using Images in Show and Scene statements without declaring them in Init.

#1 Post by Jg119 »

Hey, so recently I've been working a lot on my VN but everytime I add and image I have to declare it in the init before the start label or otherwise I get an error when loading the game or I get a white screen with the name of the image.

Since going through the motion of declaring first in a LOOOONG list of declarations I already have, is there a way to use images without declaring them first?

I know this is a total newbie question and it should be pretty simple but I can't really find the answer to it by myself, or renpy just doens't work that way.

Thanks in advance! :D
Last edited by Jg119 on Wed Aug 19, 2020 11:09 pm, edited 1 time in total.

philat
Eileen-Class Veteran
Posts: 1912
Joined: Wed Dec 04, 2013 12:33 pm
Contact:

Re: Using Images in Show and Scene statements without declaring them in Init.

#2 Post by philat »

Images are auto-defined since like... years ago. https://www.renpy.org/doc/html/displayi ... -directory

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: Using Images in Show and Scene statements without declaring them in Init.

#3 Post by Remix »

You can use the expression keyword...
Use the as keyword to set the images tag (for hiding later)

Code: Select all

    scene expression "images/backgrounds/my_pic.png"
    show expression "images/backgrounds/my_pic2.png" as piccy2
    "dialogue"
    hide piccy2
Frameworks & Scriptlets:

User avatar
qirien
Miko-Class Veteran
Posts: 541
Joined: Thu Jul 31, 2003 10:06 pm
Organization: Metasepia Games
Deviantart: qirien
Github: qirien
itch: qirien
Location: New Mexico, USA
Discord: qirien
Contact:

Re: Using Images in Show and Scene statements without declaring them in Init.

#4 Post by qirien »

As long as they are in a subdirectory called "images", Ren'py should find them for you automatically.
Finished games:
Image
Image
Image

Jg119
Newbie
Posts: 8
Joined: Tue Jan 09, 2018 7:29 am
Contact:

Re: Using Images in Show and Scene statements without declaring them in Init.

#5 Post by Jg119 »

Thanks guys, I'll try this out and see if I can get the expected results. As Philat says, I read that the images were supposed to be auto-defined but it has never work for me, is it perhaps because I use the path from "imaes/..." and not the whole "game/images/..." ?
The expression keyword is a nice workaround, so far has worked like a charm. Thanks Remix!

User avatar
qirien
Miko-Class Veteran
Posts: 541
Joined: Thu Jul 31, 2003 10:06 pm
Organization: Metasepia Games
Deviantart: qirien
Github: qirien
itch: qirien
Location: New Mexico, USA
Discord: qirien
Contact:

Re: Using Images in Show and Scene statements without declaring them in Init.

#6 Post by qirien »

All of your files for your game should be under the "game" folder (so, yes, it should be game/images). The other folders are for Ren'Py stuff.
Finished games:
Image
Image
Image

Jg119
Newbie
Posts: 8
Joined: Tue Jan 09, 2018 7:29 am
Contact:

Re: Using Images in Show and Scene statements without declaring them in Init.

#7 Post by Jg119 »

Okay I think I got it, seems it was a mistake in how I was telling renpy what image to use. Looking carefully at the renpy doc, i realized that i had to use the name of the image with no quotation marks, all lower case, and use the spaces as normal instead of adding lower bar in the spaces "_", the problem I had was that some of my images had names that conflicted wit the repny syntaxis like the word "scene" or "jump". In this case there was no need to add the "game/images/XXX". Thanks for the help!

Post Reply

Who is online

Users browsing this forum: Google [Bot]