Ren'Py Displaying a random picture with "show"

SnubbLR

Newbie
Game Developer
Sep 13, 2017
79
644
I've spent a couple of hours trying to figure this out, and really just want to puke at it.

Python:
$ twork = renpy.random.choice(['farmw1a.png', 'farmw2a.png', 'farmw3a.png', 'farmw4a.png'])
#I've defined twork both before and after the label start, but with no success (Not sure if that matters anyhow. I've always found this confusing)#
label farm:
    if yogavisit == 0:
        scene farm001
        show twork
        ys "I've got nothing to do here"
        menu:
            "Return":
                call worldmap
farmw1a etc are simple png files of a character working on a farm. I'm trying to display those randomly over my scene farm001.

All I end up with is scene farm001 with that grey renpy girl saying "twork" in the middle


What am I doing wrong here?
 

79flavors

Well-Known Member
Respected User
Jun 14, 2018
1,611
2,258
First impression:

twork is a string, not an image.

Based on this thread, and a quick glance at I think you want show expression:

Python:
$ twork = renpy.random.choice(['farmw1a.png', 'farmw2a.png', 'farmw3a.png', 'farmw4a.png'])

label farm:
    if yogavisit == 0:
        scene farm001
        show expression twork
        ys "I've got nothing to do here"
        menu:
            "Return":
                call worldmap
I've not tested it though, but it should be an easy test for you.


Edit: btw. You probably don't need the variable twork either.

Python:
label farm:
    if yogavisit == 0:
        scene farm001
        show expression renpy.random.choice(['farmw1a.png', 'farmw2a.png', 'farmw3a.png', 'farmw4a.png'])
        ys "I've got nothing to do here"
        menu:
            "Return":
                call worldmap
Though I can understand why you'd want to keep it for sanity's sake.
 
Last edited:
  • Like
Reactions: anne O'nymous

SnubbLR

Newbie
Game Developer
Sep 13, 2017
79
644
First impression:

twork is a string, not an image.

Based on this thread, and a quick glance at I think you want show expression:

Python:
$ twork = renpy.random.choice(['farmw1a.png', 'farmw2a.png', 'farmw3a.png', 'farmw4a.png'])

label farm:
    if yogavisit == 0:
        scene farm001
        show expression twork
        ys "I've got nothing to do here"
        menu:
            "Return":
                call worldmap
I've not tested it though, but it should be an easy test for you.


Edit: btw. You probably don't need the variable twork either.

Python:
label farm:
    if yogavisit == 0:
        scene farm001
        show expression renpy.random.choice(['farmw1a.png', 'farmw2a.png', 'farmw3a.png', 'farmw4a.png'])
        ys "I've got nothing to do here"
        menu:
            "Return":
                call worldmap
Though I can understand why you'd want to keep it for sanity's sake.
Expression was the answer. After declaring the files as 'farm/farmw1a.png", your last suggestion worked out very well. And yes, the variable was not needed.

Thank you so so much! You saved my night
 

anne O'nymous

I'm not grumpy, I'm just coded that way.
Modder
Donor
Respected User
Jun 10, 2017
10,976
16,232
Edit: btw. You probably don't need the variable twork either.
Put where it is, it even absolutely don't need it.
It's at top level, outside of the label. Therefore it will be proceeded only at the end of the previous label, yet only if this label don't end by a jump or a return.