Show Image with Random Choice? [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
needchocolatenow
Newbie
Posts: 10
Joined: Sun Aug 27, 2017 12:44 pm
Tumblr: https://chocodevs.tumblr.com/
itch: chocomarimo.
Contact:

Show Image with Random Choice? [solved]

#1 Post by needchocolatenow »

I'm trying to make a rock-paper-scissors mini game and I'm...kind of stuck. I would like to show an image that is associated with the random choice results, but I can't seem to get it to work? (I took out papers and scissors in my code because I wanted to test if I could get the rock picture to show up...but alas, I cannot). Am I doing everything wrong? I'm still a beginner at renpy and would like some help.

Code: Select all

define hands = ["rock"]
image rock = "images/rock.png"

init python:
    r = renpy.random.choice

label start:
    "going to choose..."
    $ result = r(hands) #THIS WILL ALWAYS BE ROCK
    "[result]"
    if result == "rock":
        show rock
    else:
        pass
return
Last edited by needchocolatenow on Thu Oct 19, 2017 10:49 pm, edited 1 time in total.

User avatar
Divona
Miko-Class Veteran
Posts: 678
Joined: Sun Jun 05, 2016 8:29 pm
Completed: The Falconers: Moonlight
Organization: Bionic Penguin
itch: bionicpenguin
Contact:

Re: Show Image with Random Choice? Help!

#2 Post by Divona »

From the code, the rock should show, but behind the textbox. Try:

Code: Select all

    if result == "rock":
        show rock:
            xalign 0.5 yalign 0.5
Completed:
Image

needchocolatenow
Newbie
Posts: 10
Joined: Sun Aug 27, 2017 12:44 pm
Tumblr: https://chocodevs.tumblr.com/
itch: chocomarimo.
Contact:

Re: Show Image with Random Choice? Help!

#3 Post by needchocolatenow »

I tried your code, but no image of the rock appears. :( I just see a blank spot where I expect an image to appear.

User avatar
Belgerum
Regular
Posts: 110
Joined: Thu Nov 06, 2014 12:24 am
Skype: belgerum09
Soundcloud: Belgerum
itch: Belgerum
Contact:

Re: Show Image with Random Choice? Help!

#4 Post by Belgerum »

When are you expecting the rock image to appear? As the code you gave runs, the image will show, but immediately be removed by the "return" command as the game returns to the main menu. Thus, the rock image is gone before the player sees it. are you sure the image wasn't meant to be shown before the "[result]" line?

needchocolatenow
Newbie
Posts: 10
Joined: Sun Aug 27, 2017 12:44 pm
Tumblr: https://chocodevs.tumblr.com/
itch: chocomarimo.
Contact:

Re: Show Image with Random Choice? Help!

#5 Post by needchocolatenow »

Oooh, I see what you mean! Yes, you're correct. I added:

Code: Select all

$ renpy.pause (2.0)
The image appeared!! Thank you so much, this helped a lot!

Post Reply

Who is online

Users browsing this forum: No registered users