Hello, I'm fairly new to making visual novels and wanted to ask a question.
How can I do it if you have a choice for example "Buy a picture" "Buy a console" or "Buy a vase", that the choice matters with the images?
I want to do it this way so that when you choose the vase, for example, you always have the background image with the vase in the future. I think I have to point out that there are several areas with different backgrounds, but I just want it to be this one background image every time the character comes back to the room.
I've already tried a little but the only thing I've come up with is that you just copy the story with the backgrounds, so basically i just make three strands from the choice with the backgrounds, but that is kinda a lot of effort for such a small change. But please correct me if i'm wrong!
I just hope that someone can help me.
Question about choices that make changes to the background
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.
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.
-
- Newbie
- Posts: 2
- Joined: Tue May 07, 2024 12:27 pm
- Contact:
- m_from_space
- Eileen-Class Veteran
- Posts: 1009
- Joined: Sun Feb 21, 2021 3:36 am
- Contact:
Re: Question about choices that make changes to the background
Hey, so there are different approaches here. The easiest way is to just store the choice inside a variable that you then use as the background.
Since you are new, let me tell you something about images in Renpy: all images inside the "game/images" folder (like jpegs and pngs) will automatically be detected by Renpy when starting your game. Renpy will then make notes inside its images store depending on the image name. So for example if you have the image "vase.png" in your images folder, you can always refer to this image by just using the string "vase", not even caring for the file extension. Now of course there should only be unique names inside your images folder for that to work.
Now let's go to your actual problem. Let's say you have the images "picture.jpg", "console.png" and "vase.png" in your images folder. Here is how you could do it:
Code: Select all
# the variable to store the background choice
# default it with an empty image object for now
default bgchoice = Null()
# the game begins
label start:
menu:
"What do you want to buy?"
"A picture":
$ bgchoice = "picture"
"A console":
$ bgchoice = "console"
"A vase":
$ bgchoice = "vase"
# now we can just use the variable, that contains a string
# it's important to use the keyword "expression" to read the contents
# otherwise Renpy would assume "bgchoice" is the name of the image
scene expression bgchoice
"What a nice choice!"
-
- Newbie
- Posts: 2
- Joined: Tue May 07, 2024 12:27 pm
- Contact:
Re: Question about choices that make changes to the background
m_from_space wrote: ↑Wed May 08, 2024 9:18 amHey, so there are different approaches here. The easiest way is to just store the choice inside a variable that you then use as the background.
Thanks alot! I just tried it and it works perfectly. I'm sorry if I bothered you with the question!
Who is online
Users browsing this forum: Google [Bot], Sugar_and_rice