Ren'Py How to make Drag&Drop restriction in RenPy

Brontozavrourus

New Member
Jun 2, 2019
2
0
So, is there some variable or condition that restricts moving objects in Drag&Drop mechanics in RenPy?

Example: I have a chest, I want the player to move things in it without throwing them outside the chest. How do I set an area beyond which the mouse/object cannot be dragged out outside of specific area?

Or, for example, I want to make an interactive scene of climbing a rope using Drag&Drop, where the player drag a hand and moves it strictly vertically along the rope. How can I disabled the movement of a dragged object horizontally and slightly limit it vertically?

I've gone through and tried all the variables in RenPy's official documentation for the Drag&Drop function. The only thing that probably would implement it is `drag_offscreen` with parameters (min_x, max_x, min_y, max_y) where I would specify negative values from the screen edges. But this doesn't work.
Python:
    draggroup:
        drag:
            xpos 0.5
            ypos 0.5
            draggable True
            drag_raise True
            drag_offscreen (-500, -500, -500, -500)
            frame:
                xpadding 20
                ypadding 20
                text "Test"
 

anne O'nymous

I'm not grumpy, I'm just coded that way.
Modder
Donor
Respected User
Jun 10, 2017
10,302
15,174
How can I disabled the movement of a dragged object horizontally and slightly limit it vertically?
Without a custom displayable that would take care of everything, you can't.

But is it really important ?
If the player release the object outside of a target, it will just return at its origin point. And globally, by themselves players will stick to a vertical movement as much as possible.


The only thing that probably would implement it is `drag_offscreen` with parameters (min_x, max_x, min_y, max_y) where I would specify negative values from the screen edges. But this doesn't work.
drag_offscreen expect a boolean value, and define if the dragged object can goes, or not, further that the physical screen boundaries. So it's not surprising that a tuple providing boundaries have no effect.
 

Brontozavrourus

New Member
Jun 2, 2019
2
0
But is it really important ?
Sort of. I wanted to add as much interactivity as possible and Drag&Drop sounds like the easiest and most logical way to add it. And prohibiting certain movements while dragging allows you to convert this into a specialised tool of storytelling.

For example, I want to do a scene with a murder investigation. I have a scene with a corpse with a knife sprite in it. I want the player to physically pull out that knife, not just click on the highlighted sprite. Looks like a simple task for Drag&Drop.

I.e. player takes that knife and pulls it strictly vertically/horizontally (i.e. that Drag&Drop movement limitation) out of the wound. If the player will be able to just take this knife and twist it in all directions as he wanted - all interactivity and imersion is lost instantly.


drag_offscreen expect a boolean value, and define if the dragged object can goes, or not, further that the physical screen boundaries. So it's not surprising that a tuple providing boundaries have no effect.
In official documentaition - yes. But here it's in Ren'Py GitHub:


~173

(min_x, max_x, min_y, max_y)
Where each of min_x, max_x, min_y, and max_y are integers.
min_x is the number of pixels away from the left border,
and max_x is the number of pixels away from the right
border. The same goes for min_y and max_y on the top and
bottom borders respectively. The drag can be moved until
one of its edges hit the specified border. (0, 0, 0, 0)
is equivalent to not allowing dragging offscreen at all.
 

anne O'nymous

I'm not grumpy, I'm just coded that way.
Modder
Donor
Respected User
Jun 10, 2017
10,302
15,174
In official documentaition - yes. But here it's in Ren'Py GitHub:
And what if I tell you that change do not magically transfer to your computer ?

You want to use an addition that will come with the version 7.5.4/8.0.4, good. But for this you need to either wait for the said version 7.5.4/8.0.4 to be released, or to rely on the nighty build and it's unstable nature.