Show a random image? [Solved]

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
pancito
Newbie
Posts: 4
Joined: Sat May 10, 2014 8:51 pm
Location: In my happy place...
Contact:

Show a random image? [Solved]

#1 Post by pancito »

So I have a tonload (not really) of potential images I want to show one of based on a random number. Here's what I have so far...

I can make up a declared image name like so:

Code: Select all

        $ num = renpy.random.randint(1, 20)
        $ thing = "thingy" + str(num)
[thing] now contains "thingy17" or whatever which is an image (image thingy17 = "thingy17.png").

Is there some way to call [thing] as in:

Code: Select all

    show thing
Given that's possible, is there some way to also declare the image on the fly, e.g. similar to:

Code: Select all

image thing = "thingy" + str(num) + ".png"
show thing
I know this is a bit weird, but I seriously don't want a huge nested if or a huge 'choice' statement. Drag to write, drag to debug, drag to document. Thanks for the help... Still learning... Still a newb.
Last edited by pancito on Mon May 12, 2014 12:55 pm, edited 1 time in total.

Asceai
Eileen-Class Veteran
Posts: 1258
Joined: Fri Sep 21, 2007 7:13 am
Projects: a battle engine
Contact:

Re: Show a random image?

#2 Post by Asceai »


pancito
Newbie
Posts: 4
Joined: Sat May 10, 2014 8:51 pm
Location: In my happy place...
Contact:

Re: Show a random image?

#3 Post by pancito »

Thank you, Asceai. I knew there had to be a way...

Post Reply

Who is online

Users browsing this forum: No registered users