init if/then behavior

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
User avatar
saguaro
Miko-Class Veteran
Posts: 556
Joined: Sun Feb 12, 2012 9:17 am
Completed: Locked-In, Sunrise, The Censor
Projects: ?
Organization: Lucky Special Games
Tumblr: saguarofoo
itch: saguarofoo
Location: USA
Contact:

init if/then behavior

#1 Post by saguaro » Sun Jul 10, 2016 9:52 pm

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?

User avatar
DragoonHP
Miko-Class Veteran
Posts: 744
Joined: Tue Jun 22, 2010 12:54 am
Completed: Christmas
IRC Nick: DragoonHP
Location: Zion Island, Solario
Contact:

Re: init if/then behavior

#2 Post by DragoonHP » Mon Jul 11, 2016 12:33 am

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

User avatar
saguaro
Miko-Class Veteran
Posts: 556
Joined: Sun Feb 12, 2012 9:17 am
Completed: Locked-In, Sunrise, The Censor
Projects: ?
Organization: Lucky Special Games
Tumblr: saguarofoo
itch: saguarofoo
Location: USA
Contact:

Re: init if/then behavior

#3 Post by saguaro » Wed Jul 13, 2016 6:05 am

Thank you, I appreciate that.

Post Reply

Who is online

Users browsing this forum: Bing [Bot], Google [Bot]