Snippets

SinnyStar [Ren'Py] Showing a list of images in python using Ren'Py functions

Created by Sinny Star
init -1 python hide:
    config.layers = [ 'master', 'mylayer', 'transient', 'screens', 'overlay' ]

label start:
    
    # img is an image file in the images folder
    # Ren'Py automatically declares it

    "Begin test"

    # works
    "show img onlayer mylayer"
    show img onlayer mylayer
    "showing"
    hide img onlayer mylayer
    "hiding"

    # works
    $ renpy.show('img', layer='mylayer')
    "showing"
    $ renpy.hide('img', layer='mylayer')
    "hiding"

    # works
    $ mylist = ['img']
    "renpy.show(img, layer='mylayer')"
    $ renpy.show(mylist[0], layer='mylayer')
    "showing"
    $ renpy.hide(mylist[0], layer='mylayer')
    "hiding"


    # The following do not work for various reasons
    # Note that img is now a reference to the image

    $ mylist = [img]

    # gray image placeholder
    $ renpy.show(mylist[0])
    "showing"
    $ renpy.hide(mylist[0])
    "hiding"

    # not found
    $ renpy.show(mylist[0], layer='mylayer')
    "showing"
    $ renpy.hide(mylist[0], layer='mylayer')
    "hiding"

    # not found
    $ myimg = mylist[0]
    $ renpy.show(myimg, layer='mylayer')
    "showing"
    $ renpy.hide(myimg, layer='mylayer')
    "hiding"

    # not found
    $ myimg = Image(mylist[0])
    $ renpy.show('myimg', layer='mylayer')
    "showing"
    $ renpy.hide('myimg', layer='mylayer')
    "hiding"

    # image attr split
    # "renpy.show(mylist, layer='mylayer')"
    # $ renpy.show(mylist[0], layer='mylayer')
    # "showing"
    # $ renpy.hide(mylist[0], layer='mylayer')
    # "hiding"

    "End test"
    return

Comments (0)

HTTPS SSH

You can clone a snippet to your computer for local editing. Learn more.