Add a random image to a screen
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.
- Keinart
- Regular
- Posts: 133
- Joined: Sun May 13, 2012 8:28 pm
- Completed: One Thousand Lies
- Projects: Lotus Reverie
- Organization: Keinart Lobre
- Tumblr: keinart
- itch: keinart
- Location: Spain
- Contact:
Add a random image to a screen
It is possible to add a random image to a menu screen? Basically I have a set of images and I want to use the Add function to display only ONE of them, randomly. So basically everytime the user opens that menu screen he will see a different image everytime.
Re: Add a random image to a screen
You have no idea how many answers to this question there are on this forum already... 
- Keinart
- Regular
- Posts: 133
- Joined: Sun May 13, 2012 8:28 pm
- Completed: One Thousand Lies
- Projects: Lotus Reverie
- Organization: Keinart Lobre
- Tumblr: keinart
- itch: keinart
- Location: Spain
- Contact:
Re: Add a random image to a screen
I've been looking for it for a while and couldn't find it, would you mind giving a hand?xela wrote:You have no idea how many answers to this question there are on this forum already...
- Keinart
- Regular
- Posts: 133
- Joined: Sun May 13, 2012 8:28 pm
- Completed: One Thousand Lies
- Projects: Lotus Reverie
- Organization: Keinart Lobre
- Tumblr: keinart
- itch: keinart
- Location: Spain
- Contact:
Re: Add a random image to a screen
I've already did that, but none of the solutions there are working for me. I've already tried different things, the one that seems to work better is this one:
Code: Select all
add renpy.random.choice(["imageone.png", "imagetwo.png", "imagethree.png"])Re: Add a random image to a screen
How about:
?
Code: Select all
screen scr():
default img = renpy.random.choice(["imageone.png", "imagetwo.png", "imagethree.png"])
add img
- Keinart
- Regular
- Posts: 133
- Joined: Sun May 13, 2012 8:28 pm
- Completed: One Thousand Lies
- Projects: Lotus Reverie
- Organization: Keinart Lobre
- Tumblr: keinart
- itch: keinart
- Location: Spain
- Contact:
Re: Add a random image to a screen
Ahh, it works. I knew I wasn't thinking correctly, I just had to put a new screen inside the screen, that makes sense. Thank you for the help!xela wrote:How about:
?Code: Select all
screen scr(): default img = renpy.random.choice(["imageone.png", "imagetwo.png", "imagethree.png"]) add img
Who is online
Users browsing this forum: No registered users
