Transform on show and showif/else [sort of solved]

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
Milkymalk
Miko-Class Veteran
Posts: 753
Joined: Wed Nov 23, 2011 5:30 pm
Completed: Don't Look (AGS game)
Projects: KANPEKI! ★Perfect Play★
Organization: Crappy White Wings
Location: Germany
Contact:

Transform on show and showif/else [sort of solved]

#1 Post by Milkymalk »

What I tried to do:
A button has icons partially hidden behind it. When the button is hovered, the icons spread out and go next to the button, until the button is unhovered, when they will retract and only be partially visible behind the button again.

I figured I would do this with a showif, either showing the expanding/retracting, or the stationary retracted icons. It works, but if I include the marked "else" statement, the "on show" part of the transform "questicons" does never execute. The "on show" from the transform "questiconswait", however, seems to work normally.

If I comment out the "else" part, "questicons" works perfectly.

I'm assuming the other transform somehow disturbs the first transform, but I can't find out how or what I have to do to make it work. What also puzzles me is that the second transform's "on show" does work.

Code: Select all

init python:
    
    class Quest:
        def __init__(self, characters, bg, label):
            self.icons = []
            for c in characters:
                self.icons.append(character_icon[c])
            self.bg = bg
            self.label = label
            
        def execute(self):
            renpy.call(self.label)
            
default character_icon = {'red': slide_red, 'green': slide_green, 'blue': slide_blue}
default myquest = Quest(['red', 'green', 'blue'], 'images/idle_buttonlong.png', 'questlabel')
default hoveredquest = None

define slide_red = Solid('#ff0000', xysize=(50,50))
define slide_green = Solid('#00ff00', xysize=(50,50))
define slide_blue = Solid('#0000ff', xysize=(50,50))

transform questicons(x):
    xpos -10*(x+1)
    xanchor 0.0
    yalign .5
    on show:
        linear 0.12 xpos -155*(x+1)
    on hide:
        linear 0.12 xpos -10*(x+1)

transform questiconswait(x):
    xanchor 0.0
    yalign .5
    xpos -10*(x+1)
    on show:
        alpha 0.0
        0.12
        alpha 1.0

screen questbutton(quest):
    style_prefix "questbutton"
    fixed:
        xalign 1.0
        xfit True
        vbox:
            fixed:
                ysize 65
                xfit True
                showif hoveredquest == quest:
                    for n, i in reversed(list(enumerate(reversed(quest.icons)))):
                        add i at questicons(n)
                else:				                                            # <--- THIS
                    for n, i in reversed(list(enumerate(reversed(quest.icons)))):
                        add i at questiconswait(n)

                imagebutton:
                    idle quest.bg
                    action Jump(myquest.label)
                    hovered SetVariable('hoveredquest', quest)
                    unhovered SetVariable('hoveredquest', None)

label start:
    show screen questbutton(myquest)
    # more stuff
Last edited by Milkymalk on Sat May 09, 2020 4:34 pm, edited 1 time in total.
Crappy White Wings (currently quite inactive)
Working on: KANPEKI!
(On Hold: New Eden, Imperial Sea, Pure Light)

User avatar
Milkymalk
Miko-Class Veteran
Posts: 753
Joined: Wed Nov 23, 2011 5:30 pm
Completed: Don't Look (AGS game)
Projects: KANPEKI! ★Perfect Play★
Organization: Crappy White Wings
Location: Germany
Contact:

Re: Transform on show and showif/else

#2 Post by Milkymalk »

Half-solved; I tried "showif hoveredquest != quest" and swap the two blocks, and that solved the issue. No idea why though.
Crappy White Wings (currently quite inactive)
Working on: KANPEKI!
(On Hold: New Eden, Imperial Sea, Pure Light)

Post Reply

Who is online

Users browsing this forum: Google [Bot]