(solved)How do I script a reposition of drag within a screen?

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
SONTSE
Regular
Posts: 98
Joined: Sun Nov 24, 2013 10:49 pm
Completed: 11 VN's so far
Discord: jkx0282_10798
Contact:

(solved)How do I script a reposition of drag within a screen?

#1 Post by SONTSE »

Let's say I have a screen with a draggable object inside

Code: Select all

screen say(who, what):
    style_prefix "say"
    drag:
        drag_name 'screen_say'
        window:
            id "window"
    
            if who is not None:
    
                window:
                    id "namebox"
                    style "namebox"
                    text who id "who"
    
            text what id "what"
and I want it to move into a certain position, ideally with ease effect something like

Code: Select all

    e 'and now i move your draggable say screen!'
    show screen_say:
        ease .5 pos (0,400)
    pause 1
    e 'see? it's moving. It's alive!'
unfortunately it seems transforms cannot be applied directly on screens, and I have no idea of how to approach the drag within a screen. So I would be thankful for any suggestions!
Last edited by SONTSE on Fri Feb 15, 2019 11:32 am, edited 1 time in total.

User avatar
Remix
Eileen-Class Veteran
Posts: 1628
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: How do I script a reposition of drag within a screen?

#2 Post by Remix »

Maybe (untested)

$ renpy.get_widget( "say", "screen_say" ).snap( 0, 400, 0.5 )
Frameworks & Scriptlets:

User avatar
SONTSE
Regular
Posts: 98
Joined: Sun Nov 24, 2013 10:49 pm
Completed: 11 VN's so far
Discord: jkx0282_10798
Contact:

Re: How do I script a reposition of drag within a screen?

#3 Post by SONTSE »

Remix wrote: Thu Feb 14, 2019 9:32 pm Maybe (untested)

$ renpy.get_widget( "say", "screen_say" ).snap( 0, 400, 0.5 )
Thanks! That surely did lead to a working solution.
Although it won't work like this because no say screen is shown when $ scripts are executed,
hence get_widget returns None instead of a widget.
So there is some tricky way to actually get this done.

Code: Select all

init python:
    def drag_move(drag):
        try:
            drag.snap(0,400,delay=.5)
        except:
            pass

screen move_drag:
    default say_drag = renpy.get_widget('say','drag')
    timer 1 action Function(drag_move,say_drag)

screen say(who, what):
    on 'show' action Show('move_drag')    
    drag:
        style_prefix "say"
        drag_name "screen_say"
        id "drag"
        yalign 1.0
        window:
            id "window"       
            if who is not None:
                window:
                    id "namebox"
                    style "namebox"
                    text who id "who"
            text what id "what"

label main_menu:
    return

label start:
    'Look! It\'s moving!'
    'It\'s alive!'
    return


Post Reply

Who is online

Users browsing this forum: Ahrefs [Bot], GetOutOfMyLab