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.
-
VimislikArt
- Regular
- Posts: 90
- Joined: Sun Mar 06, 2016 6:50 pm
- Projects: King of the Cul-De-Sac
- Deviantart: vimislikart
- itch: vimislikart
- Location: Rochester, NY
-
Contact:
#1
Post
by VimislikArt » Tue Aug 17, 2021 11:08 pm
I'm using Ren'py's
Drag and Drop system to let players lay out documents, and open them in whatever sequence they want, jumping to new scenes. But, when I jump to a new scene, and return back to the drag and drop layout, the images reset to their original positions.
Is there a way to save the x,y coordinates when each document gets moved, and when the player leaves and comes back, the draggables can be arranged in the same positions the player left them?
Code: Select all
screen drag_test_pretest:
draggroup:
drag:
drag_name "Document1"
drag_raise True
droppable False
clicked [ToggleScreen("drag_test_pretest", transition=None), Call("cutscene")]
frame:
has vbox
label "Cutscene"
text "This will display a cutscene"
drag:
drag_name "Document2"
drag_raise True
droppable False
clicked [ToggleScreen("drag_test_pretest", transition=None), Show("document")]
frame:
has vbox
label "Display Document"
text "This will display a larger version of the document"
drag:
drag_name "Document3"
child "dragdrop_item1.png"
drag_raise True
droppable False
frame:
has vbox
label "This does nothing"
text "really"
-
rayminator
- Miko-Class Veteran
- Posts: 754
- Joined: Fri Feb 09, 2018 12:05 am
- Location: Canada
-
Contact:
#2
Post
by rayminator » Wed Aug 18, 2021 12:13 am
you have to tell renpy that one drag and drop that it has been done
-
VimislikArt
- Regular
- Posts: 90
- Joined: Sun Mar 06, 2016 6:50 pm
- Projects: King of the Cul-De-Sac
- Deviantart: vimislikart
- itch: vimislikart
- Location: Rochester, NY
-
Contact:
#3
Post
by VimislikArt » Wed Aug 18, 2021 9:03 am
rayminator wrote: ↑Wed Aug 18, 2021 12:13 am
you have to tell renpy that one drag and drop that it has been done
Is this a reference to the "droppable False" property? If that's what you mean, that just means other drags can't be dropped on this object (like putting an image in a slot). I tried turning it off
juuust in case, but it made no difference.
If that isn't what you meant, can you elaborate on what "tell renpy that one drag and drop that it has been done" means? I see that the documentation has a "dragged" property, that can call up a def...
Code: Select all
drag:
drag_name "Ivy"
child "ivy.png"
droppable False
dragged detective_dragged
xpos 100 ypos 100
Code: Select all
init python:
def detective_dragged(drags, drop):
if not drop:
return
store.detective = drags[0].drag_name
store.city = drop.drag_name
return True
...but I'm not sure how to call up the x,y fields of a dropped object, or how to set up a definition like this to take advantage of it.
I was hoping there was some displayable property I was just misunderstanding that would solve my issue.
-
rayminator
- Miko-Class Veteran
- Posts: 754
- Joined: Fri Feb 09, 2018 12:05 am
- Location: Canada
-
Contact:
#4
Post
by rayminator » Wed Aug 18, 2021 11:06 am
-
Alex
- Lemma-Class Veteran
- Posts: 2981
- Joined: Fri Dec 11, 2009 5:25 pm
-
Contact:
#5
Post
by Alex » Wed Aug 18, 2021 12:23 pm
VimislikArt wrote: ↑Tue Aug 17, 2021 11:08 pm
...Is there a way to save the x,y coordinates when each document gets moved, and when the player leaves and comes back, the draggables can be arranged in the same positions the player left them?...
You need a kind of variable to store positions of all documents and a function, that will change the values of this variable.
Try
Code: Select all
default docs_positions = {
'Document1':(100, 100),
'Document2':(150, 150),
'Document3':(200, 200),
}
screen drag_test_pretest():
draggroup:
drag:
pos docs_positions['Document1'] # <---
drag_name "Document1"
drag_raise True
droppable False
dragged store_docs_position # <---
clicked [ToggleScreen("drag_test_pretest", transition=None), Call("cutscene")]
frame:
has vbox
label "Cutscene"
text "This will display a cutscene"
drag:
pos docs_positions['Document2']
drag_name "Document2"
drag_raise True
droppable False
dragged store_docs_position
#clicked [ToggleScreen("drag_test_pretest", transition=None), Show("document")]
frame:
has vbox
label "Display Document"
text "This will display a larger version of the document"
drag:
pos docs_positions['Document3']
drag_name "Document3"
#child "dragdrop_item1.png"
drag_raise True
droppable False
dragged store_docs_position
frame:
has vbox
label "This does nothing"
text "really"
init python:
def store_docs_position(drags, drop):
store.docs_positions[drags[0].drag_name] = (drags[0].x, drags[0].y)
# The game starts here.
label start:
"..."
show screen drag_test_pretest
"move some docs"
hide screen drag_test_pretest
"..."
show screen drag_test_pretest
"?!"
Another sample -
viewtopic.php?f=8&t=58381#p526695
-
VimislikArt
- Regular
- Posts: 90
- Joined: Sun Mar 06, 2016 6:50 pm
- Projects: King of the Cul-De-Sac
- Deviantart: vimislikart
- itch: vimislikart
- Location: Rochester, NY
-
Contact:
#6
Post
by VimislikArt » Wed Aug 18, 2021 1:13 pm
Alex wrote: ↑Wed Aug 18, 2021 12:23 pm
You need a kind of variable to store positions of all documents and a function, that will change the values of this variable.
Thank you! That would have taken me a week to figure out on my own

! I'll throw it in engine tonight and give'er a try!
Users browsing this forum: enaielei, Google [Bot]