Page 1 of 1

using images as variable[solved]

Posted: Fri Dec 11, 2020 11:39 pm
by cedes
I'm trying to use a random picked image of a scratch to appear, but I can't get the image to show up correctly?

Code: Select all

label scratch_pic:

    $ scratch= "should be image"



    $ scratch6 = 'images/scratch6.png'
    $ scratch5 = 'images/scratch5.png'
    $ scratch4 = 'images/scratch4.png'
    $ scratch3 = 'images/scratch3.png'
    $ scratch2 = 'images/scratch2.png'
    $ scratch1 = 'images/scratch1.png'

    $r = renpy.random.randint(1,6)

    "[scratch] [r]"

    if r == 1:
        $scratch = scratch1
    if r == 2:
        $scratch = scratch2
    if r == 3:
        $scratch = scratch3
    if r == 4:
        $scratch = scratch4
    if r == 5:
        $scratch = scratch5
    if r == 6:
        $scratch = scratch6

    return
This is the code I'm using to try to randomly pick an image, and using this:

Code: Select all

show scratch at ec1
to try to show it at a userdefined location, but it just shows up as a shadow.

The image is in the right location, if i write show scratch4 then it shows up fine but I can't get it down in this way!

Re: using images as variable

Posted: Fri Dec 11, 2020 11:46 pm
by hell_oh_world
should be...

Code: Select all

show expression scratch at ec1
also might be the shortest and easiest way...

Code: Select all

show expression "images/scratch{}.png".format(renpy.random.randint(1, 6)) at ec1

Re: using images as variable[solved]

Posted: Sun Dec 13, 2020 6:13 pm
by cedes
oh perfect thanks! Works perfect now, thanks for the shortcut as well!

Re: using images as variable[solved]

Posted: Wed Dec 16, 2020 8:30 am
by cedes
Question, how do I get to hide the image?

I tried to hide image and it's showing up as invalid!

Re: using images as variable[solved]

Posted: Wed Dec 16, 2020 9:15 am
by hell_oh_world
You tag them then hide them using that tag.

Code: Select all

show expression "something.png" as something
hide something