DynamicImages in an imagebutton don't work

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
Adrian_DVL
Regular
Posts: 93
Joined: Fri Mar 15, 2019 8:46 am
Projects: Clockwork Poison
Contact:

DynamicImages in an imagebutton don't work

#1 Post by Adrian_DVL » Thu Mar 26, 2020 12:44 pm

Hi, mates!

Here's the thing: I have this action on an imagebutton:

Code: Select all

action Show('videos', girl=girl)
Which leads to a screen that shows an image depending on the girl (object) of a list (class) that is passed as the parameter. This works fine, and the button leads to the screen, which is this one:

Code: Select all

screen videos(girl):
    modal True
    if unlock_vid:
        add "girls/[girl.name]_videos.png" pos (122, 76)
        if girl.vid1:
            imagebutton:
                idle "girls/[girl.name]_vid1.png"
                hover "girls/[girl.name]_hvid1.png"
                pos (156, 291)
                action None
        if girl.vid2:
            imagebutton:
                idle "girls/[girl.name]_vid2.png"
                hover "girls/[girl.name]_hvid2.png"
                pos (156, 502)
                action None
The problem is that the screen displays the [girl_name]_videos.png but does not display the [girl_name]_vid1.png, etc. I get a crash instead. And yes, I have the correct images in the correct folder with the correct extension.

The funny thing comes once you read the traceback. If I delete the _videos.png, the traceback is as follows (for instance, for an object whose name is Lucy):

Exception: DynamicImage u'girls/[girl.name]_videos.png': could not find image. (u'girls/Lucy_videos.png')

As I said, when that image is in the folder, it is correctly displayed on the screen. On the contrary, the traceback I get with the other images is this one:

Exception: DynamicImage u'girls/[girl.name]_hvid1.png': could not find image. (u'girls/[girl.name]_hvid1.png')

As you can see, it's like in the first case the game knows exactly what's the name of the file that it's looking for, but in the second case, it doesn't.
Why is this? How can I do to get to display the vid1, hvid1, vid2 and hvid2 images? Thank you!

User avatar
gas
Miko-Class Veteran
Posts: 717
Joined: Mon Jan 26, 2009 7:21 pm
Contact:

Re: DynamicImages in an imagebutton don't work

#2 Post by gas » Thu Mar 26, 2020 1:24 pm

Dunno, but try retrieve the name before using it in the imagebutton.

Code: Select all

if unlock_vid:
        add "girls/[girl.name]_videos.png" pos (122, 76)
        if girl.vid1:
            $ dagal = girl.name
            imagebutton:
                idle "girls/[dagal]_vid1.png"
                hover "girls/[dagal]_hvid1.png"
I think the error is there as an impossibility to dynamically interpolate the value AND retrieve it at the same time when rendering.
If you want to debate on a reply I gave to your posts, please QUOTE ME or i'll be not notified about.

10 ? "RENPY"
20 GOTO 10

RUN

Adrian_DVL
Regular
Posts: 93
Joined: Fri Mar 15, 2019 8:46 am
Projects: Clockwork Poison
Contact:

Re: DynamicImages in an imagebutton don't work

#3 Post by Adrian_DVL » Thu Mar 26, 2020 1:37 pm

gas wrote:
Thu Mar 26, 2020 1:24 pm
Dunno, but try retrieve the name before using it in the imagebutton.

Code: Select all

if unlock_vid:
        add "girls/[girl.name]_videos.png" pos (122, 76)
        if girl.vid1:
            $ dagal = girl.name
            imagebutton:
                idle "girls/[dagal]_vid1.png"
                hover "girls/[dagal]_hvid1.png"
I think the error is there as an impossibility to dynamically interpolate the value AND retrieve it at the same time when rendering.
Didn't work. Same result. I even tried creating that variable inside of an init block, in fact inside of the same init block where I have the class, but I got the same outcome. Thanks, anyways!

Adrian_DVL
Regular
Posts: 93
Joined: Fri Mar 15, 2019 8:46 am
Projects: Clockwork Poison
Contact:

Re: DynamicImages in an imagebutton don't work

#4 Post by Adrian_DVL » Thu Mar 26, 2020 3:01 pm

Update on this: since it seems I can't put a dynamic image neither in an imagebutton nor inside an imagemap, what I've done is "add" the dynamic image before the imagebutton, and for the imagebutton I just put a fader, just like this:

Code: Select all

if unlock_vid:
        add "girls/[girl.name]_videos.png" pos (122, 76)
        if girl.vid1:
            add "girls/[girl.name]_v1.png" pos (156, 291)
            imagebutton:
                idle "girls/vnone.png"
                hover "girls/vfader.png"
                pos (156, 291)
Anyway, if anyone knows why I can't use a dynamic image in an imagebutton, it'd be great!

User avatar
Remix
Eileen-Class Veteran
Posts: 1413
Joined: Tue May 30, 2017 6:10 am
Completed: None... yet (as I'm still looking for an artist)
Projects: An un-named anime based trainer game
Contact:

Re: DynamicImages in an imagebutton don't work

#5 Post by Remix » Thu Mar 26, 2020 8:22 pm

Generally you can, just you cannot when the interpolated value is based on a local (screen) variable
Frameworks & Scriptlets:

Post Reply

Who is online

Users browsing this forum: Google [Bot], Majestic-12 [Bot], MaydohMaydoh