How to make transforms reset, or repeat, each time used

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
LyannaCore
Newbie
Posts: 22
Joined: Wed Jun 21, 2017 1:45 pm
Contact:

How to make transforms reset, or repeat, each time used

#1 Post by LyannaCore »

I may have the terminology wrong, but basically I have a sort of tablet interface that rises from off screen, then expands for use.
Clicking an icon causes it to rise and expand, and clicking it again reverses the movements, closing and lowering.

HOWEVER, if I then click the button again, it merely hides and shows it in place, no more nice rising opening or lowering closing.
Probably something obvious I missed, but would appreciate suggestions.

Code: Select all

init offset = -1

##Screen Overlay##
init python:
    def konokolifted_function(trans, st, at):
        SetScreenVariable("konoko_lifted", True)

    def konokolowered_function(trans, st, at):
        SetScreenVariable("konoko_lowered", True)
        SetScreenVariable("konoko_hidden", True)
            

transform konoko_lift:
    yoffset 900
    easein_quint 1.0 yoffset 0
    function konokolifted_function
    
transform konoko_lower:
    yoffset 0
    pause 0.9
    easeout_quint 1.0 yoffset 900
    function konokolowered_function
    
transform konoko_open:
    "gui/hud/KonokoScreen1.png" 
    xzoom 0 
    pause 0.9
    ease_quad 1.0 xzoom 1.01
    pause 0.02
    xzoom 1.0

transform konoko_close:
    "gui/hud/KonokoScreen1.png" 
    xzoom 1.0
    xzoom 1.01
    pause 0.02
    ease_quad 1.0 xzoom 0
    
screen hud_overlay():
        #tag hud
    default textbox_down = True
    default konoko_hidden = True
    default konoko_shown = False
    default konoko_lifted = False
    default konoko_lowered = True
    default konoko_startup = True
    default fuelquantity = "{size=30}{k=-2}00{/k}{/size}"
    default partsquantity = "{size=30}{k=-2}00{/k}{/size}"
    default ruyenquantity = "{size=30}{k=-2}0000{/k}{/size}"
    
    frame:
        xpadding 0
        ypadding 0
        left_margin 19
        top_margin 19
        background None
        xalign 0.0
        yalign 0.0
        hbox:
            add im.Alpha("gui/hud/ShortBlackBoxes.png", 0.4)
            xsize 314
            ysize 46
        hbox:
            add im.Alpha("gui/hud/LongBlackBox.png", 0.4)
            xsize 315
            ysize 29
            ypos 60
        hbox:
            add im.Alpha("gui/hud/LongBlackBox.png", 0.4)
            xsize 315
            ysize 29
            ypos 92
        hbox:
            xpos 210
            ypos 125
            imagebutton: 
                auto "gui/hud/KonokoButton1_%s.png"
                focus_mask None
                if konoko_hidden == True and konoko_lowered == True:
                    action [SetScreenVariable("konoko_hidden", False), SetScreenVariable("konoko_lowered", False)]
                elif konoko_hidden == False and konoko_lowered == False:
                    action [SetScreenVariable("konoko_hidden", True), SetScreenVariable("konoko_lowered", True), SetScreenVariable("konoko_startup", False)]
        hbox:
            xpos 5
            ypos 8
            imagebutton: 
                auto "gui/hud/Fuel2_%s.png"
                focus_mask None
                action NullAction
            hbox:
                yoffset -1
                xoffset 12
                text fuelquantity
                
        hbox:
            xpos 99
            ypos 7
            imagebutton: 
                auto "gui/hud/Parts2_%s.png"
                focus_mask None
                action NullAction
            hbox:
                yoffset -1
                xoffset 8
                text partsquantity
        hbox:
            xpos 194
            ypos 8
            imagebutton: 
                auto "gui/hud/Ruyen2_%s.png"
                focus_mask None
                action NullAction
            hbox:
                xanchor 0
                yoffset -1
                xoffset 2
                text ruyenquantity
                
    if textbox_down == True:
        vbox:
            xsize 1230
            ysize 262
            xalign 0.5
            yalign 1.0
            imagebutton: 
                auto "gui/hud/DialogBox_%s.png"
                focus_mask True
                action SetScreenVariable("textbox_down", False)
    else:
        vbox:
            xsize 1228
            ysize 34
            xalign 0.5
            yalign 1.0
            yoffset -8
            imagebutton: 
                auto "gui/hud/DialogBoxHidden_%s.png"
                focus_mask True
                action SetScreenVariable("textbox_down", True)
                
    frame:
        xpadding 0
        ypadding 0
        background None
        xalign 0.5
        yalign 0.4
        
            hbox:                ## Starts closed and out of sight.
                xoffset -370
                yoffset 900
                add "gui/hud/KonokoLeft1.png"
                add "gui/hud/KonokoScreen1.png" at konoko_close
                imagebutton: 
                    auto "gui/hud/KonokoRight1_%s.png"
                    focus_mask True
                    action NullAction
                SetScreenVariable("konoko_startup", True)


        if konoko_hidden == False and konoko_lowered == False: ## i.e. konoko should be open and visible
            hbox at konoko_lift:
                add "gui/hud/KonokoLeft1.png"
                add "gui/hud/KonokoScreen1.png" at konoko_open
                imagebutton: 
                    auto "gui/hud/KonokoRight1_%s.png"
                    focus_mask True
                    action [SetScreenVariable("konoko_hidden", True), SetScreenVariable("konoko_lowered", True), SetScreenVariable("konoko_startup", False)]
                
        pass
        
        if konoko_hidden == True and konoko_lowered == True and konoko_startup == False:
            hbox at konoko_lower:
                add "gui/hud/KonokoLeft1.png"
                add "gui/hud/KonokoScreen1.png" at konoko_close
                imagebutton: 
                    auto "gui/hud/KonokoRight1_%s.png"
                    focus_mask True
                    action [SetScreenVariable("konoko_hidden", False), SetScreenVariable("konoko_lowered", False)]
                
        pass
                    
    add "gui/hud/ScreenOutline.png"

User avatar
DannyGMaster
Regular
Posts: 113
Joined: Fri Sep 02, 2016 11:07 am
Contact:

Re: How to make transforms reset, or repeat, each time used

#2 Post by DannyGMaster »

Try using the on statement in your screen to call your transform whenever the screen is shown or hidden.

EDIT: I linked to the wrong section, really sorry. Refer to philat's post below for the correct links.
Last edited by DannyGMaster on Tue Jul 04, 2017 8:23 am, edited 1 time in total.
The silent voice within one's heart whispers the most profound wisdom.

LyannaCore
Newbie
Posts: 22
Joined: Wed Jun 21, 2017 1:45 pm
Contact:

Re: How to make transforms reset, or repeat, each time used

#3 Post by LyannaCore »

I tried using on, but it's throwing up an error when I try and show the screen, specifically when I click the imagebutton that contains: action [Show("konoko")

Code: Select all

I'm sorry, but an uncaught exception occurred.

While running game code:
  File "game/script.rpy", line 649, in script
    shop1 "Hello, can I help you?"
TypeError: 'unicode' object is not callable

-- Full Traceback ------------------------------------------------------------

Full traceback:
  File "game/script.rpy", line 649, in script
    shop1 "Hello, can I help you?"
  File "C:\renpy-6.99.12.4-sdk\renpy\ast.py", line 613, in execute
    renpy.exports.say(who, what, interact=self.interact)
  File "C:\renpy-6.99.12.4-sdk\renpy\exports.py", line 1147, in say
    who(what, interact=interact)
  File "C:\renpy-6.99.12.4-sdk\renpy\character.py", line 877, in __call__
    self.do_display(who, what, cb_args=self.cb_args, **display_args)
  File "C:\renpy-6.99.12.4-sdk\renpy\character.py", line 716, in do_display
    **display_args)
  File "C:\renpy-6.99.12.4-sdk\renpy\character.py", line 508, in display_say
    rv = renpy.ui.interact(mouse='say', type=type, roll_forward=roll_forward)
  File "C:\renpy-6.99.12.4-sdk\renpy\ui.py", line 285, in interact
    rv = renpy.game.interface.interact(roll_forward=roll_forward, **kwargs)
  File "C:\renpy-6.99.12.4-sdk\renpy\display\core.py", line 2526, in interact
    repeat, rv = self.interact_core(preloads=preloads, trans_pause=trans_pause, **kwargs)
  File "C:\renpy-6.99.12.4-sdk\renpy\display\core.py", line 2746, in interact_core
    new_widget=layers_root)
TypeError: 'unicode' object is not callable

Windows-8-6.2.9200
Ren'Py 6.99.12.4.2187
Space Lanes 0.01a
Current code:

Code: Select all

################################################################################
## Initialization
################################################################################

init offset = -1

##Screen Overlay##

transform konoko_show:
    yoffset 900
    easein_quint 1.0 yoffset 0

    
transform konoko_hide:
    yoffset 0
    pause 0.9
    easeout_quint 1.0 yoffset 900


screen konoko():
    frame:
        xpadding 0
        ypadding 0
        background None
        xalign 0.5
        yalign 0.4
        hbox: 
            xoffset -370
            add "gui/hud/KonokoLeft1.png"
            imagebutton: 
                auto "gui/hud/KonokoRight1_%s.png"
                focus_mask True
                action NullAction
                
    on "show" action With("konoko_show")
    on "hide" action With("konoko_hide")


screen hud_overlay():

    default textbox_down = True
    default konoko_hidden = True

    default fuelquantity = "{size=30}{k=-2}00{/k}{/size}"
    default partsquantity = "{size=30}{k=-2}00{/k}{/size}"
    default ruyenquantity = "{size=30}{k=-2}0000{/k}{/size}"
    
    frame:
        xpadding 0
        ypadding 0
        left_margin 19
        top_margin 19
        background None
        xalign 0.0
        yalign 0.0
        hbox:
            add im.Alpha("gui/hud/ShortBlackBoxes.png", 0.4)
            xsize 314
            ysize 46
        hbox:
            add im.Alpha("gui/hud/LongBlackBox.png", 0.4)
            xsize 315
            ysize 29
            ypos 60
        hbox:
            add im.Alpha("gui/hud/LongBlackBox.png", 0.4)
            xsize 315
            ysize 29
            ypos 92
        hbox:
            xpos 210
            ypos 125
            imagebutton: 
                auto "gui/hud/KonokoButton1_%s.png"
                focus_mask None
                if konoko_hidden == True:
                    action [Show("konoko"), SetScreenVariable("konoko_hidden", False)]
                elif konoko_hidden == False:
                    action [Hide("konoko"), SetScreenVariable("konoko_hidden", True)]
        hbox:
            xpos 5
            ypos 8
            imagebutton: 
                auto "gui/hud/Fuel2_%s.png"
                focus_mask None
                action NullAction
            hbox:
                yoffset -1
                xoffset 12
                text fuelquantity
                
        hbox:
            xpos 99
            ypos 7
            imagebutton: 
                auto "gui/hud/Parts2_%s.png"
                focus_mask None
                action NullAction
            hbox:
                yoffset -1
                xoffset 8
                text partsquantity
        hbox:
            xpos 194
            ypos 8
            imagebutton: 
                auto "gui/hud/Ruyen2_%s.png"
                focus_mask None
                action NullAction
            hbox:
                xanchor 0
                yoffset -1
                xoffset 2
                text ruyenquantity
                
    if textbox_down == True:
        vbox:
            xsize 1230
            ysize 262
            xalign 0.5
            yalign 1.0
            imagebutton: 
                auto "gui/hud/DialogBox_%s.png"
                focus_mask True
                action SetScreenVariable("textbox_down", False)
    else:
        vbox:
            xsize 1228
            ysize 34
            xalign 0.5
            yalign 1.0
            yoffset -8
            imagebutton: 
                auto "gui/hud/DialogBoxHidden_%s.png"
                focus_mask True
                action SetScreenVariable("textbox_down", True)
                
    add "gui/hud/ScreenOutline.png"

User avatar
DannyGMaster
Regular
Posts: 113
Joined: Fri Sep 02, 2016 11:07 am
Contact:

Re: How to make transforms reset, or repeat, each time used

#4 Post by DannyGMaster »

I see, it might be because With() is receiving "konoko_show" and "konoko_hide" as strings, try removing
the " " and see if it works.
The silent voice within one's heart whispers the most profound wisdom.

LyannaCore
Newbie
Posts: 22
Joined: Wed Jun 21, 2017 1:45 pm
Contact:

Re: How to make transforms reset, or repeat, each time used

#5 Post by LyannaCore »

Unfortunately that just gives a different error:

Code: Select all

I'm sorry, but an uncaught exception occurred.

While running game code:
  File "game/script.rpy", line 653, in script
    shop1 "Hello, can I help you?"
Exception: Parameter 'new_widget' is not known by ATL Transform.

-- Full Traceback ------------------------------------------------------------

Full traceback:
  File "game/script.rpy", line 653, in script
    shop1 "Hello, can I help you?"
  File "C:\renpy-6.99.12.4-sdk\renpy\ast.py", line 613, in execute
    renpy.exports.say(who, what, interact=self.interact)
  File "C:\renpy-6.99.12.4-sdk\renpy\exports.py", line 1147, in say
    who(what, interact=interact)
  File "C:\renpy-6.99.12.4-sdk\renpy\character.py", line 877, in __call__
    self.do_display(who, what, cb_args=self.cb_args, **display_args)
  File "C:\renpy-6.99.12.4-sdk\renpy\character.py", line 716, in do_display
    **display_args)
  File "C:\renpy-6.99.12.4-sdk\renpy\character.py", line 508, in display_say
    rv = renpy.ui.interact(mouse='say', type=type, roll_forward=roll_forward)
  File "C:\renpy-6.99.12.4-sdk\renpy\ui.py", line 285, in interact
    rv = renpy.game.interface.interact(roll_forward=roll_forward, **kwargs)
  File "C:\renpy-6.99.12.4-sdk\renpy\display\core.py", line 2526, in interact
    repeat, rv = self.interact_core(preloads=preloads, trans_pause=trans_pause, **kwargs)
  File "C:\renpy-6.99.12.4-sdk\renpy\display\core.py", line 2746, in interact_core
    new_widget=layers_root)
  File "C:\renpy-6.99.12.4-sdk\renpy\atl.py", line 413, in __call__
    raise Exception('Parameter %r is not known by ATL Transform.' % k)
Exception: Parameter 'new_widget' is not known by ATL Transform.

Windows-8-6.2.9200
Ren'Py 6.99.12.4.2187
Space Lanes 0.01a

User avatar
DannyGMaster
Regular
Posts: 113
Joined: Fri Sep 02, 2016 11:07 am
Contact:

Re: How to make transforms reset, or repeat, each time used

#6 Post by DannyGMaster »

Oh, you re right, its because With expects a transition instead of a transform. Try your original code but put the if statement to the konoko frame, and inside the if use the at statement, add at konoko_show if hidden and at konoko_hide if visible, and the like. I hope that made sense, cant make an example because on mobile browser right now but it should work.
The silent voice within one's heart whispers the most profound wisdom.

philat
Eileen-Class Veteran
Posts: 1912
Joined: Wed Dec 04, 2013 12:33 pm
Contact:

Re: How to make transforms reset, or repeat, each time used

#7 Post by philat »

Not gonna attempt to wade through the entire thing, but here's a simple working prototype.

Code: Select all

transform test_transform:
    on show, replace:
        yoffset 900
        easein_quint 1.0 yoffset 0
    on hide, replaced:
        yoffset 0
        easeout_quint 1.0 yoffset 900


screen hud_overlay():
    vbox:
        text "HUD OVERLAY SCREEN SHOWING"
        textbutton "show konoko" action Show("konoko")

screen konoko():

    frame:
        at test_transform
        xpadding 0
        ypadding 0
        background None
        xalign 0.5
        yalign 0.4
        vbox:
            add Solid("#FFF", xysize=(1000, 300))
            textbutton "hide konoko" action Hide("konoko")

label start:
    show screen hud_overlay()
    "Use buttons to show/hide the screen"

LyannaCore
Newbie
Posts: 22
Joined: Wed Jun 21, 2017 1:45 pm
Contact:

Re: How to make transforms reset, or repeat, each time used

#8 Post by LyannaCore »

Thank you both for the help, I had no idea what replace/replaced did since they aren't explained in the documentation for on, merely listed as a parameter.

philat
Eileen-Class Veteran
Posts: 1912
Joined: Wed Dec 04, 2013 12:33 pm
Contact:

Re: How to make transforms reset, or repeat, each time used

#9 Post by philat »

That's actually a different thing entirely. What you linked to executes screen actions on a particular event. The ATL on statement applies an ATL transform on a particular event. (https://www.renpy.org/doc/html/atl.html#on-statement / https://www.renpy.org/doc/html/atl.html#external-events)

They're mostly named the same, but they have different syntax (note the quotes around show in the screen language version) and are separate things, really.

The point is that you should pull that on show/hide concept into the transform and apply the transform without other conditions in the screen, rather than the other way around (note that I only have one transform, whereas you had separate transforms for show and hide).

I won't pretend that renpy can't be really effing confusing at times ;)

Post Reply

Who is online

Users browsing this forum: Google [Bot]