Page 1 of 1

init if/then behavior

Posted: Sun Jul 10, 2016 9:52 pm
by saguaro
I have encountered an issue while using Leon's gallery code. I'm not sure if I'm missing something.

The gallery works fine until you introduce an if/then statement that changes the gallery image list based on a boolean variable.

Code: Select all

image cg c1 = "blahblah.png"
...

init:    
    if uncensored_patch:
        $ gallery_cg_items = [ "cg c1", "cg c2", ...  ]
    else:
        $ gallery_cg_items = [ "cg c1b", "cg c2b", ...]
This error is produced by the following code

While running game code:
File "game/screens.rpy", line 842, in script
init +1 python:
File "game/screens.rpy", line 845, in <module>
renpy.image (gal_item + " butt", im.Scale(ImageReference(gal_item), thumbnail_x, thumbnail_y))
Exception: Expected an image, but got a general displayable.

Code: Select all

init +1 python:
    #Here we create the thumbnails. We create a grayscale thumbnail image for BGs, but we use a special "locked" image for CGs to prevent spoilers.
    for gal_item in gallery_cg_items:
        renpy.image (gal_item + " butt", im.Scale(ImageReference(gal_item), thumbnail_x, thumbnail_y))
Using ATL instead of an image manipulator "works" except there's a scaling issue, so the thumbnails created this way have artifacts and don't look good.

Code: Select all

...
renpy.image (gal_item + " butt", At(gal_item, gallery_button_size)) 
...        

transform gallery_button_size:
    subpixel True
    size (thumbnail_x, thumbnail_y)  
I have gone around and around with this, and I am not sure why the error is thrown when the if/then statement is used for gallery_cg_items. What's going on here?

Re: init if/then behavior

Posted: Mon Jul 11, 2016 12:33 am
by DragoonHP
Usually this error means that one of the images in gallery_cg_items does not exist. viewtopic.php?f=51&t=22465&hilit=button ... 45#p310657

Re: init if/then behavior

Posted: Wed Jul 13, 2016 6:05 am
by saguaro
Thank you, I appreciate that.