Drag ideas: 1. A magnifying glass that magnified what was under the "lens" 2. A towel that could wipe away steam on a mirror or something covered in dust. 3. A fingerprint brush to search for hidden fingerprint clues. 4. A UV lamp that showed clues (like dried blood or a secret message)
Seriously, you make the most high quality and entertaining videos about renpy that I've seen on TH-cam. It's really motivating me to keep working on my game :)
I’m definitely rewatching all those videos multiple times and pausing every 30 seconds to comprehend. It’s simple and yet complex. All those functions are truly game changers. Thank you for sharing
omg this is AMAZING. I've been wanting to do a VN that had a crafting system and every person I spoke to made it seem like it was nigh impossible and here's the drag and drop feature just...existing. Thanks so much for this!
Damn. This is pretty neat stuff. Would love to see in-depth tutorials and examples on dragging too. Such as opening curtains to see what's behind them and so forth. But this is already super helpful.
Outstanding tutorial as usual, mixing both the technical part of the subject and your thoughts about how to take advantage of it in a narrative. Hats off once again!
This is the second time I've come to investigate Ren'py, because I'm interested in how to go beyond the fundamental, boring, way of approaching the UI, question-answer, multiple choice-pick, scenarios. Your videos always pop up in the list and I've loved them. There's another author that shows how to build the logic for a character creator system that's amazing. I really appreciate these shares!
THANK YOU SO MUCH. I can't even begin to express how grateful I am for this tutorial. I'm working on a VN in Ren'py that involves a part (or perhaps a minigame) in which you have the option to move birds around and today I was finally able to implement this. I was inspired by the code in your video (to which I made some minor tweaks and added some pictures of birds i took myself) to keep working on it until I finally got it right. I started moving the birds around a bit myself for a youtube video I uploaded and afterwards I continued to move around those birds on the screen for HOURS. It was so satisfying, an almost childlike sense of joy overcame me. This wouldn't have happened without the inspiration I found with this video (and i haven't even tried the "drop" part of "drag and drop" yet). thank you
Having to shove the girl feels vile lmao I definitely wouldn't be able to make that choice if it was in a tactile format. My friends and I used to play escape room games over vc and having to collect and then drag components into puzzles always felt really good, especially when you would spend a bunch of time dragging the component places it wasn't supposed to go and then finally found the place where it was and unlocked something new. Personally, I'm thinking of creating a game that requires you to ask the right questions to certain characters to learn more about the world it's set in, so being able to take objects to them and have them comment seems like a fun way to use this system and introduce some interactability. Thank you for the tutorial! Cheers!
Card games! Lol, you mentioned some other cool ideas here too I hadn't thought of, but my immediate thought for this feature is card games :D. Thanks for the cool video!
I love your content. I'm learning ren'py to create an educational game and your videos really help me to understando what I can do or not. =) Thanks a lot!
Thanks so much for this!! :D Love your videos, so inspiring. Also, subscriber #1000! (At least it looks that way from my screen!) :) Keep up the awesome work.
Thank you so much for these videos! I am trying to figure out how to implement this into a spell casting system, which is basically just crafting. I want the player to drag "runes" to a certain spot, in a certain order, so I have been trying to take this video and make the former using if statements. And I am utterly failing! There is another tutorial series that talks about a crafting inventory system, but I am coding impaired and its hard for me to follow. Your tutorials are awesome, especially for an artist like me trying to add some functionality and gameplay to my VN! I didn't know if you have any recommendations on how to go about creating it with the code from the video from as a launching point. Thank you so much!!
I have a question, more than an idea(🤣): let’s say we are making a gardening scene and we want our players to move their hands + pick a vase with topsoil in it + drag it around a tree (and, the moment they pick it, the image of the vertical vase changes to a horizontal one with topsoil falling to the ground + they can only drag it following a pre-established perfect circular shape. How do we do all of that?
Lots of different ways that all have their own advantages and disadvantages. Before you get to deep into what you "ideally want" though, you'll want to establish what you "need". Yes, you could create a custom cursor that activates when you press a button, and then create several more screen buttons with new hover states that permanently change when you hover over them in sequence, OR, you can make the user drag and drop one batch of dirt at a time, which requires way less code. The best solution is often the simplest, because the more complicated you make something, the more opportunities it has to break on you.
@@vimi thank you so much for taking in consideration my question!!🥺💓 I’ll take the best from your suggestion, I appreciate it, truly, thank you again🥹💓
It's a really solid start, but I would like to see a follow-up tutorial on the more complex features. The demos you showed are amazing, but I'm struggling to re-create them.
Are there any particular aspects you're consistently having trouble with? I included the code I used in a github link in the description, if that's any help!
@@vimi Hey, sorry for the late reply. So here's what I tried to do: >Click and drag a herb to a bowl and drop it in. >I wanted the herb to light up when dragged >I wanted the bowl to light up when hovered over it with the herb. Turns out... not as easy as I thought! Eventually got help via the Renpy Discord. It never turned out exactly the way I wanted it, but it's close, so I'm quite happy =)
Ty! This was really helpful for me during this game jam i'm in rn! But, quick question: which file are we supposed to use for the code? The script.rpy, screen.rpy, or something else?
The short answer is "script.rpy". The long answer is "anywhere; ren'py starts your game at label start, and after that, as long as you make sure your game jumps or calls other labels and screens, you can really put your code anywhere. I end up adding a ton of extra rpy files just to split everything up into manageable chunks for later! "
Thank you so much for this video. Really helped me out with my project. I have one question, how do you prevent the dialog from continuing if the drag&drop screen is showing? and how to continue the dialogue after the drag and drop is closed? This is the code I have: eileen "hey there!" show screen dragNDropTest with dissolve eileen "how are you?" the eileen dialogue keeps on playing when the drag and drop screen is open
That one I faked with a screen record! But if you wanted to make something like that, it would be a simple screen where the knife is the draggable object, and make Caesar an image that changes depending on a variable that changes when you drop the object on to him.
This helped a lot, but there's one more thing I can't figure out how to do; Play a sound when a Drag is clicked. I guess you need some python code to do it...
Hello 👋🏼👋🏼I'm slowly seeing your videos which I'm finding really useful. In particular on the drag and drop question I wanted to ask you something: I currently have an object x which combined with object y creates object z. Until here it's ok but then I would like to make object z an imagebutton to jump in a new path and sincerely i wouldn't know how to do it ...do you have any advice ?🫤
You can do it in a few different ways depending on your specific needs. As a little hint, you can put if/else statements inside of some definitions of objects. So instead of add "image.png", maybe you can say "add" and then make that an image defined earlier, that has an if/else statement inside that changes the image if a variable changes. So you could make both items X and Y so they have default images, but when you combine them, set off a variable that changes the image of item X to the new item as a hyperlink, and hides item Y. There's a few other ways you can handle it, but being able to define images, functions, and other variables with if/else statements will probably be a huge part of whatever you go with!
I got a question regarding drag function. Can I use it to allow the user to only move the object in one axis? Let's say its x axis. I intended to use it for a minigame where you simply move an object in fixed time interval.
It's amazing what you do and I don't have words to say anything that hasn't been said in the comments! But I have a question, how could I place two "draggable" elements in a "droppable"?
Do you know how to call on a Drag's properties? Like, if I want to make an if statement where "if circle's xpos is greater than 500" (cuz it's dragged that far from its starting xpos of 100 by the player), "e "xpos is greater than 500!"" or something? Every if statement I make trying to use circle's properties comes back with an "undefined" error :(
I copied and pasted your same code into renpy 8.2.0 and i got this error: NameError: name 'droppable' is not defined i'm using the latest version of atom please it would be amazing if you told me how to fix this, i really want to know how to make use of this great drag n drop function
Love the channel! I saw a vague suggestion that the drag/drop system might be able to be used to act as a collision detection system. I was wondering if you had thoughts on how that might be possible? I'm thinking maybe, big IF, the draggable "item" was already in motion and were to "collide" with the droppable item, some defined action takes place (call function or add to score, etc...). IF that were possible, things could get more interesting with more moving pieces, but just as a simple example, do you know if something like that would be possible?
@@vimi Oh sweet, I'm very interested in seeing what you come up with. I'm expanding my understanding and knowledge every day and collision detection is the next hurdle for me. Your videos are a huge help for me.
Great video, thank you so much! I just have a quick question: I'm trying to make a word bank mini game where you drag words onto a blank space to complete a sentence. This code works great, except it always resets the words. Is there a way to make it so it does not return to the beginning of the screen? I want to place words down and keep them there.
The easiest way to do this, in your case, is to create two objects; the word you need to drag, and then the area you're dropping the word into. When you drop the word onto the space, the word needs to be set so it hides itself when it's dropped, and the space, when dropped onto, checks to see what's been dropped on it, and then displays what that is.
hello, it`s me again, im binge watching all of your videos to make a good novel for jam) 1) i have a question - i literally copipasted code for draganddrop, made my bg and pngs for my "circles squares" and so on, but i can`t proceed with novel after it`s one drag - was dropped in one of the circles, they don`t leave screen and just hang there for the rest of game. is there some sort of "clear screen and return to game" command? 2) also somehow my drags don`t drop majestically in my "left circle" and "right circle", as yours, they just hang there and I am not sure if I missed something, what corresponds to this action in code? basically, what i want, is to have the ability to go through a pack of notebooks and sort them into two categories, find one special - and proceed to talk with other characters, proceed to play right now I have icons, bg for it, and the code is like yours *as it seems* but i feel like i am missing something and i don`t know where to look cause of nonexistent basic knowledge of coding and poor knowledge of coding English, so I am sorry if my questions seem stupid to u, i am SURE they are!!
1) You can use "call" instead of "show" for your screen - I used the show screen so I could show the dialogue afterwords! 2) In the if/else statements after the screen, I have a bunch of code that sets x and y coordinates for a new circle or triangle, based on what's dropped in where - otherwise, as long as draggable overlaps a droppable, even by a pixel, it counts that!
I'm a bit late, and I'm not sure I you'll see this, but I'm having a lot of trouble. I'm basically trying to create something similar to the Caesar being stabbed thing you showed. I made a draggable and a droppable but nothing happens when the draggable is dropped onto the droppable. I've tried various solutions and even tried to use the "dropped" function but couldn't figure it out due to several different errors. Basically, after dragging the draggable to the droppable, I want to hide the screen and jump to a different part of the script. Do you know how I would go about doing that?
Hey I know this is a bit old now. But I’m trying to delay the return in my drag and drop. I want it to do a few things first like snap to position, play a sound, then return True after a second or so the close the screen and continue with the script. Any idea how to do this?
Yeah; in my example script there, once the image snapped into the right spot, I removed the drag'n'drop screen, and replicated the placement of all of the elements on a separate screen. You'd want to do that, and then use regular ATL language to play the sound and do all the feedback and everything.
how would one remove a dragged item once it dropped on a droppable? For example in the video, if a circle is dropped in a circle droppable, what is the best way to remove it?
@@jessicaherrera7900 This code isn't even in Python - this is code for Ren'py specifically. If you want Javascript drag and drop code, try this: www.javascripttutorial.net/web-apis/javascript-drag-and-drop/
Hello, I don't know much English, I have a doubt.... How can I do that when I use the drag and drop and grab the object and drop it anywhere, this same object not having reached its target, returns to its original position? thanks in advance, very good content!
There's a few different ways - easiest is to just call the screen, and when the input is made, call the screen again. That resets everything back to the way it was originally.
I have a question I can't seem to get answered anywhere else; I can't seem to combine this method with the cooking timer. When dragging/moving the draggable items, it doesn't show the fluid motion as I'm moving/dragging it; it "teleports" around. Removing the timer screen solves it, and I get fluid motion when dragging something, but adding the timer back just causes the draggable to "teleport" again. Is there any way to get a draggable item (as shown in your circle/square/triangle example), along with a timer so that the player has to match the shapes as fast as possible within the time limit?
It sounds like your game is getting resource heavy somehow??? You can try removing the bar function and seeing if the timer functionality is specifically what's causing that issue, and if it is, maybe increasing the units of time from a hundredth of a second to a tenth or a whole second would be the best bet (and then replace the bar functionality with an animated image)? If you get it to work, let me know what fixed it!
You'd have to create a defined event, and activate it using any of the callbacks like activated, dragging, dragged, dropped, or clicked. These example events from the ren'py documentation are basically the sort you'd want: www.renpy.org/doc/html/character_callbacks.html#example
Okay so I feel like I'm missing something: What chunk of code actually serves as the trigger to make the game DO something when the draggable is dropped in the droppable?
At 3:22, that's the custom definition that stores the drag/drop items names, and exits the user out of the screen if the user drags an item to a droppable.
@@vimi thanks for the reply! That helps, but is there any chance you happen to have a video up already that would describe what exactly those lines of code are communicating with? Like I understand that that code chunk will do what you laid out in the video. But if I wanted to modify it to just link to another screen or something, or jump to a particular label, or even use it on the start menu to start the game up initially, I don't really understand the code laid out here, well enough to modify it to my purposes. If you have another video that maybe delves more into that topic or if you know of one, would you mind pointing me in its direction?
It's a great video, I just have a lot of difficulty understanding things unless I can see all the way down to the roots of it. Certain renpy functionality is really obvious as to how it communicates with Python. I'm having trouble with this one though, so a little bit of an x-ray as to what exactly it's doing, how we're communicating with the dropped dragged, alternate activated, etc. Etc functions would be really helpful. Maybe it's something I should just go to reddit for. And if so feel free to tell me! Thanks again for this video and all the time you put into this and taking the time to respond to me
Broadly speaking, When an item is dragged, I call this custom definition, drag_placed (dragged drag_placed in the drag item). In the definition, the first two lines just return back to the drag screen without doing anything else, so as long as you are actively dragging an item, the definition is waiting for you to drop the drag item into a droppable item. If you do not drop it onto a droppable item, then the definition does not do anything. Once the drag item is dropped, it's storing two values: the first is the term "draggable", which is the name of the thing you are dragging (store.draggable = drags[0].drag_name). In the second line, you're storing the name of the item you dropped in "droppable" by seeing what the drag item was moved to (store.droppable = drop.drag_name). Then, it returns a value, True (return True). How I use this in practice, is that I CALL a screen with the drag group (drag_sample 2), so when one of the items is dragged to one of the droppable items, the called screen disappears, because the definition drag_placed is returning a value, but not before it stores the two variable names for me. Then, I use a little visual trickery to give the illusion of some permanence to the screen. Now with those variables, I show a new screen, drag_sample3, which just shows the droppable items in their same positions, but with the draggable items removed. Then, I have some if statements that display elements based on the two newly stored values: store.draggable and store.droppable. I set an x-position value based on if they picked the left or right circle (droppable), and then I see what object was dragged (draggable), and then I only display that one object along the y axis of the circles, and use the x position value to center it on the left or right circle. Then, I list out where the object is placed, by using our stored values to display their names - "The [draggable] was put in [droppable]". ESSENTIALLY, all you need to know is that if you call a drag screen, you can use this code to get the name of the thing that was dragged, and the thing that was dropped, and then you can do whatever you want with that information - move them to a different part of your game, alter a value, or even bring them back to the drag/drop screen to do it again. From there, you're limited by your imagination!
@@vimi okay that's really helpful, I'm gonna try and implement that to make sure I understand it. Thank you so much for providing such a thorough and patient answer, also. Love your videos, and have a great day!
On your ren'py launcher, under the "Navigate Script" section, press the text that says "Build Distributions". It will bring you to a new page that lets you name the zip file it will build, as well as the name of the executable file inside. Press "Build", and it will upload a zip file to the folder where ren'py is located on your computer. If you want to build your game for android or iOS, there are separate sections with their own distribution items listed there. www.renpy.org/doc/html/quickstart.html#releasing-your-game
as of 2024, with Ren'Py 8.2, the if statement doesn't work because (for some reason), "draggable" and "droppable" are not defined. It's bizarre, it's like being forced to define the "play" code command. anyway, this is the code that's not working: if drag_placed.droppable == "Meteor Card": $ xpos_var = 150 if draggable == "Fire": show Fire: xpos xpos_var ypos 460
Correct, "draggable" and "droppable" are not defined, because you have to define them yourself. That's what the code at the 3:18 is for. You don't always want to necessarily define the names; instead of the function "drag_placed", you can replace it with anything else that does the associated action. So instead of those if statements you have there, you could call an action that instead just does the position changes and image calls you need. Way more efficient. If you included the drag_placed code, and it's that text that isn't working, then replace the "drag_placed.droppable" with just "droppable".
Drag ideas:
1. A magnifying glass that magnified what was under the "lens"
2. A towel that could wipe away steam on a mirror or something covered in dust.
3. A fingerprint brush to search for hidden fingerprint clues.
4. A UV lamp that showed clues (like dried blood or a secret message)
Seriously, you make the most high quality and entertaining videos about renpy that I've seen on TH-cam. It's really motivating me to keep working on my game :)
Thank you! Keep working on your game!!!
Truth
Totally agree!!!💓
I’m definitely rewatching all those videos multiple times and pausing every 30 seconds to comprehend. It’s simple and yet complex. All those functions are truly game changers. Thank you for sharing
Thanks!
I'm not even planning on making a RenPy game, I just watch these for fun and try to understand, even though my English is not the best :D
I had no idea that renpy had such a cool functionality, you seriously help so much with everything that you do!
Yay! I'm glad to hear that!
Yeahhh, I’m so grateful too🥹💓💓
omg this is AMAZING. I've been wanting to do a VN that had a crafting system and every person I spoke to made it seem like it was nigh impossible and here's the drag and drop feature just...existing. Thanks so much for this!
Awesome!
i am already pogged at Regular Brain- THE TEXT MOVES
Damn. This is pretty neat stuff. Would love to see in-depth tutorials and examples on dragging too. Such as opening curtains to see what's behind them and so forth. But this is already super helpful.
I like to use my Ren'py Cookbook series for those sorts of thing - a bunch more of those are in the pipeline, so keep an eye out!
Another absolute banger. You have no idea how much you're helping my game out!
That's great to hear! I'll TRY to imagine how much I'm helping!
Seriously I didn't see the potential of drag and drop system until you showed your exemples !!! Thank you sm I have so many ideas now !!
It's really an underutilized feature!
Outstanding tutorial as usual, mixing both the technical part of the subject and your thoughts about how to take advantage of it in a narrative. Hats off once again!
🎩😃
This is the second time I've come to investigate Ren'py, because I'm interested in how to go beyond the fundamental, boring, way of approaching the UI, question-answer, multiple choice-pick, scenarios. Your videos always pop up in the list and I've loved them. There's another author that shows how to build the logic for a character creator system that's amazing. I really appreciate these shares!
Thanks!
Its so cool, we will try to implement it. Since my favourite VN ever (Va11-Hall-A) centers the game around this particular mechanic.
Awesome!
Just found your channel while working on a project, wonderful quality and content, thank you for taking your time to work on it ❤
Thank YOU for taking the time to watch my videos!
This is SO AWESOME, thank you so much for making this tutorial! I've been really wanting to learn about drag and drop programming in Ren'Py.
THANK YOU SO MUCH. I can't even begin to express how grateful I am for this tutorial. I'm working on a VN in Ren'py that involves a part (or perhaps a minigame) in which you have the option to move birds around and today I was finally able to implement this.
I was inspired by the code in your video (to which I made some minor tweaks and added some pictures of birds i took myself) to keep working on it until I finally got it right.
I started moving the birds around a bit myself for a youtube video I uploaded and afterwards I continued to move around those birds on the screen for HOURS. It was so satisfying, an almost childlike sense of joy overcame me. This wouldn't have happened without the inspiration I found with this video (and i haven't even tried the "drop" part of "drag and drop" yet). thank you
OH! I saw this video!!! I'm so glad I inspired you! Keep at it!
Really nice tutorials! It's nice to see high-quality content about Renp'y, keep up the great work!
Thank you! I'll keep at it!
Epic chapter meme names XD Thank you so much for this video!
i put waaaaay too much time into the chapter titles, so I'm glad you appreciate them!
Thank you for this video, it inspired me to conceptualize some interesting drag/drop ideas for my game.
Nice! I'm glad this video gave you some idea fuel!
This channel is such a hidden gem, hope you blow up
🙏Thank you!
I was exactly looking for something like this, thank you!!! amazing video
Very punny at the end :D. Thanks for the tips and tutorial!
Having to shove the girl feels vile lmao I definitely wouldn't be able to make that choice if it was in a tactile format. My friends and I used to play escape room games over vc and having to collect and then drag components into puzzles always felt really good, especially when you would spend a bunch of time dragging the component places it wasn't supposed to go and then finally found the place where it was and unlocked something new. Personally, I'm thinking of creating a game that requires you to ask the right questions to certain characters to learn more about the world it's set in, so being able to take objects to them and have them comment seems like a fun way to use this system and introduce some interactability. Thank you for the tutorial! Cheers!
Really appreciate the break down! Hopefully I can find use in the VN once I have the dialogue all written lol
Card games!
Lol, you mentioned some other cool ideas here too I hadn't thought of, but my immediate thought for this feature is card games :D.
Thanks for the cool video!
Card games would work! That would be a GREAT application for this!
I love your content. I'm learning ren'py to create an educational game and your videos really help me to understando what I can do or not. =) Thanks a lot!
You're welcome!
This series is so useful. Keep it up!
I've got a few more tutorial videos in me!
Thank you so much!! I was wondering how to do such thing for a long time
Glad I could help!
Just pressing the like button is too cold. That's why, hey! Thanks for the video, it really helped me with a project!
Glad I could help!
Thanks for making these videos, very helpful
Please do a video explaining how to make a card game with Renpy, including common card game mechanics like shuffling the cards.
Finally, now I can make Rupaul's Drag Race into a novel
Wow! Thank you so much for this!
You're welcome!!!
Thanks so much for this!! :D Love your videos, so inspiring.
Also, subscriber #1000! (At least it looks that way from my screen!) :) Keep up the awesome work.
Thank you! And yeah, I'm absolutely stoked to hit 1000!!!
Years ago I was trying to figure out how to have a shooting minigame, this will solve that issue!
Thanks for making these videos!
DRESS UP GAME
Great video, btw!
LOL! Now I wanna find a Ren'py game that does this! Or...do it myself???
its actualy usefull when you're making a puzzle type game.
I absolutely love how tactile it makes puzzles feel!
needed this
Glad to help!
Really greatfull i found this channel, great video.
I'm really grateful you found this channel too!
Some parts of this video may be outdated. Code similar to code in the video at 3:38 gets NameError : name 'draggable' not defined.
That error messaging sounds like the drag_name wasn't defined in the drag screen like you can see at 1:51 .
Thank you so much for these videos! I am trying to figure out how to implement this into a spell casting system, which is basically just crafting. I want the player to drag "runes" to a certain spot, in a certain order, so I have been trying to take this video and make the former using if statements. And I am utterly failing! There is another tutorial series that talks about a crafting inventory system, but I am coding impaired and its hard for me to follow. Your tutorials are awesome, especially for an artist like me trying to add some functionality and gameplay to my VN! I didn't know if you have any recommendations on how to go about creating it with the code from the video from as a launching point. Thank you so much!!
drag and drop is 👌
I have a question, more than an idea(🤣):
let’s say we are making a gardening scene and we want our players to move their hands + pick a vase with topsoil in it + drag it around a tree (and, the moment they pick it, the image of the vertical vase changes to a horizontal one with topsoil falling to the ground + they can only drag it following a pre-established perfect circular shape.
How do we do all of that?
Lots of different ways that all have their own advantages and disadvantages.
Before you get to deep into what you "ideally want" though, you'll want to establish what you "need". Yes, you could create a custom cursor that activates when you press a button, and then create several more screen buttons with new hover states that permanently change when you hover over them in sequence, OR, you can make the user drag and drop one batch of dirt at a time, which requires way less code.
The best solution is often the simplest, because the more complicated you make something, the more opportunities it has to break on you.
@@vimi thank you so much for taking in consideration my question!!🥺💓 I’ll take the best from your suggestion, I appreciate it, truly, thank you again🥹💓
Amazing, hope you grow dude, you are great explaining. Would love to assist to a course of yours.
I'll probably need some help at some point lol
Gotta get back to dev work soon!
It's a really solid start, but I would like to see a follow-up tutorial on the more complex features.
The demos you showed are amazing, but I'm struggling to re-create them.
Are there any particular aspects you're consistently having trouble with?
I included the code I used in a github link in the description, if that's any help!
@@vimi Hey, sorry for the late reply. So here's what I tried to do:
>Click and drag a herb to a bowl and drop it in.
>I wanted the herb to light up when dragged
>I wanted the bowl to light up when hovered over it with the herb.
Turns out... not as easy as I thought! Eventually got help via the Renpy Discord. It never turned out exactly the way I wanted it, but it's close, so I'm quite happy =)
It's so cool! Thanks
No prob!
Ty! This was really helpful for me during this game jam i'm in rn! But, quick question: which file are we supposed to use for the code? The script.rpy, screen.rpy, or something else?
The short answer is "script.rpy".
The long answer is "anywhere; ren'py starts your game at label start, and after that, as long as you make sure your game jumps or calls other labels and screens, you can really put your code anywhere. I end up adding a ton of extra rpy files just to split everything up into manageable chunks for later! "
Thank you so much for this video. Really helped me out with my project. I have one question, how do you prevent the dialog from continuing if the drag&drop screen is showing? and how to continue the dialogue after the drag and drop is closed?
This is the code I have:
eileen "hey there!"
show screen dragNDropTest with dissolve
eileen "how are you?"
the eileen dialogue keeps on playing when the drag and drop screen is open
Would it be possible to link the code you used to the stabbing Caesar bit? I'm trying to do something similar, but I'm struggling to get it done.
That one I faked with a screen record!
But if you wanted to make something like that, it would be a simple screen where the knife is the draggable object, and make Caesar an image that changes depending on a variable that changes when you drop the object on to him.
This helped a lot, but there's one more thing I can't figure out how to do; Play a sound when a Drag is clicked. I guess you need some python code to do it...
Hello 👋🏼👋🏼I'm slowly seeing your videos which I'm finding really useful. In particular on the drag and drop question I wanted to ask you something: I currently have an object x which combined with object y creates object z. Until here it's ok but then I would like to make object z an imagebutton to jump in a new path and sincerely i wouldn't know how to do it ...do you have any advice ?🫤
You can do it in a few different ways depending on your specific needs. As a little hint, you can put if/else statements inside of some definitions of objects.
So instead of add "image.png", maybe you can say "add" and then make that an image defined earlier, that has an if/else statement inside that changes the image if a variable changes.
So you could make both items X and Y so they have default images, but when you combine them, set off a variable that changes the image of item X to the new item as a hyperlink, and hides item Y.
There's a few other ways you can handle it, but being able to define images, functions, and other variables with if/else statements will probably be a huge part of whatever you go with!
I got a question regarding drag function. Can I use it to allow the user to only move the object in one axis? Let's say its x axis. I intended to use it for a minigame where you simply move an object in fixed time interval.
I don't think so. You might be better off using a bar with most of the displayables turned off except for the thumb displayable.
It's amazing what you do and I don't have words to say anything that hasn't been said in the comments! But I have a question, how could I place two "draggable" elements in a "droppable"?
I'll have to double check later, but I think that can be done by default!
@@vimi Thanks for your answer!! I'll try to do some testing on my side too
Do you know how to call on a Drag's properties?
Like, if I want to make an if statement where "if circle's xpos is greater than 500" (cuz it's dragged that far from its starting xpos of 100 by the player), "e "xpos is greater than 500!"" or something?
Every if statement I make trying to use circle's properties comes back with an "undefined" error :(
I copied and pasted your same code into renpy 8.2.0 and i got this error:
NameError: name 'droppable' is not defined
i'm using the latest version of atom
please it would be amazing if you told me how to fix this, i really want to know how to make use of this great drag n drop function
same
Dragon Drop sounds like a video game
Love the channel! I saw a vague suggestion that the drag/drop system might be able to be used to act as a collision detection system. I was wondering if you had thoughts on how that might be possible? I'm thinking maybe, big IF, the draggable "item" was already in motion and were to "collide" with the droppable item, some defined action takes place (call function or add to score, etc...). IF that were possible, things could get more interesting with more moving pieces, but just as a simple example, do you know if something like that would be possible?
I'm working on a system like this right now, and I don't think drag and drop is the pathway to the solution.
@@vimi Oh sweet, I'm very interested in seeing what you come up with. I'm expanding my understanding and knowledge every day and collision detection is the next hurdle for me. Your videos are a huge help for me.
Hi, keep up the good work!
🥰👍
What software did you used for the creation of characters in romancing flesh? It looks like still images that are somehow animated.
I used Photoshop for the image composites, and then animated them in Live2d, with lots of meshes!
Great video, thank you so much! I just have a quick question: I'm trying to make a word bank mini game where you drag words onto a blank space to complete a sentence. This code works great, except it always resets the words. Is there a way to make it so it does not return to the beginning of the screen? I want to place words down and keep them there.
The easiest way to do this, in your case, is to create two objects; the word you need to drag, and then the area you're dropping the word into.
When you drop the word onto the space, the word needs to be set so it hides itself when it's dropped, and the space, when dropped onto, checks to see what's been dropped on it, and then displays what that is.
hello, it`s me again, im binge watching all of your videos to make a good novel for jam)
1) i have a question - i literally copipasted code for draganddrop, made my bg and pngs for my "circles squares" and so on, but i can`t proceed with novel after it`s one drag - was dropped in one of the circles, they don`t leave screen and just hang there for the rest of game. is there some sort of "clear screen and return to game" command?
2) also somehow my drags don`t drop majestically in my "left circle" and "right circle", as yours, they just hang there and I am not sure if I missed something, what corresponds to this action in code?
basically, what i want, is to have the ability to go through a pack of notebooks and sort them into two categories, find one special - and proceed to talk with other characters, proceed to play
right now I have icons, bg for it, and the code is like yours *as it seems* but i feel like i am missing something and i don`t know where to look cause of nonexistent basic knowledge of coding and poor knowledge of coding English, so I am sorry if my questions seem stupid to u, i am SURE they are!!
1) You can use "call" instead of "show" for your screen - I used the show screen so I could show the dialogue afterwords!
2) In the if/else statements after the screen, I have a bunch of code that sets x and y coordinates for a new circle or triangle, based on what's dropped in where - otherwise, as long as draggable overlaps a droppable, even by a pixel, it counts that!
@@vimi oh, thank you very much for replying!!! i will try everything, thank you again so so mucn!!
I'm a bit late, and I'm not sure I you'll see this, but I'm having a lot of trouble. I'm basically trying to create something similar to the Caesar being stabbed thing you showed. I made a draggable and a droppable but nothing happens when the draggable is dropped onto the droppable. I've tried various solutions and even tried to use the "dropped" function but couldn't figure it out due to several different errors. Basically, after dragging the draggable to the droppable, I want to hide the screen and jump to a different part of the script. Do you know how I would go about doing that?
I'd just take the code I included in the description, and work from there.
@@vimi I tried that and couldn’t figure it out. But it’s fine! I was able to come up with another way to do it with some more research. Thank you!
Hey I know this is a bit old now. But I’m trying to delay the return in my drag and drop. I want it to do a few things first like snap to position, play a sound, then return True after a second or so the close the screen and continue with the script. Any idea how to do this?
Yeah; in my example script there, once the image snapped into the right spot, I removed the drag'n'drop screen, and replicated the placement of all of the elements on a separate screen.
You'd want to do that, and then use regular ATL language to play the sound and do all the feedback and everything.
how would one remove a dragged item once it dropped on a droppable? For example in the video, if a circle is dropped in a circle droppable, what is the best way to remove it?
There's a few ways to do it, but off the top of my head, set a callback to "Hide" when an object is dropped is probably the easiest!
Have you ever used Visual Novel Maker? Where would you put this type of code in the game? Thanks for the tutorials!
I haven't used Visual Novel Maker, but I imagine you can't use this code in there - different engines need different code 🤷♂
@@vimi It says it uses JavaScript and coffeeScript. I just don't know where to add it. :)
@@jessicaherrera7900 This code isn't even in Python - this is code for Ren'py specifically. If you want Javascript drag and drop code, try this:
www.javascripttutorial.net/web-apis/javascript-drag-and-drop/
Hello, I don't know much English, I have a doubt.... How can I do that when I use the drag and drop and grab the object and drop it anywhere, this same object not having reached its target, returns to its original position? thanks in advance, very good content!
Would this work for a crafting system? My game is going to have that and I’m unsure if this would work for it
It would work as a tactile element for a crafting system, but the actual inventory and crafting systems are going to be a bit more complicated!
How do you make the item dragable and clickable? Ive been trying to figure it out for a while
Also when you rop them in the right place how to change the scene back to normal
There's a few different ways - easiest is to just call the screen, and when the input is made, call the screen again. That resets everything back to the way it was originally.
I have a question I can't seem to get answered anywhere else;
I can't seem to combine this method with the cooking timer.
When dragging/moving the draggable items, it doesn't show the fluid motion as I'm moving/dragging it; it "teleports" around.
Removing the timer screen solves it, and I get fluid motion when dragging something, but adding the timer back just causes the draggable to "teleport" again.
Is there any way to get a draggable item (as shown in your circle/square/triangle example), along with a timer so that the player has to match the shapes as fast as possible within the time limit?
It sounds like your game is getting resource heavy somehow???
You can try removing the bar function and seeing if the timer functionality is specifically what's causing that issue, and if it is, maybe increasing the units of time from a hundredth of a second to a tenth or a whole second would be the best bet (and then replace the bar functionality with an animated image)?
If you get it to work, let me know what fixed it!
Hey, how do i add a sound to a dragable object?
You'd have to create a defined event, and activate it using any of the callbacks like activated, dragging, dragged, dropped, or clicked.
These example events from the ren'py documentation are basically the sort you'd want:
www.renpy.org/doc/html/character_callbacks.html#example
@@vimi thanks!!
Do you think hover could work as well?
Does someone know where I can find a tutorial for a drag and drop sorting minigame?
Okay so I feel like I'm missing something: What chunk of code actually serves as the trigger to make the game DO something when the draggable is dropped in the droppable?
At 3:22, that's the custom definition that stores the drag/drop items names, and exits the user out of the screen if the user drags an item to a droppable.
@@vimi thanks for the reply! That helps, but is there any chance you happen to have a video up already that would describe what exactly those lines of code are communicating with? Like I understand that that code chunk will do what you laid out in the video. But if I wanted to modify it to just link to another screen or something, or jump to a particular label, or even use it on the start menu to start the game up initially, I don't really understand the code laid out here, well enough to modify it to my purposes. If you have another video that maybe delves more into that topic or if you know of one, would you mind pointing me in its direction?
It's a great video, I just have a lot of difficulty understanding things unless I can see all the way down to the roots of it. Certain renpy functionality is really obvious as to how it communicates with Python. I'm having trouble with this one though, so a little bit of an x-ray as to what exactly it's doing, how we're communicating with the dropped dragged, alternate activated, etc. Etc functions would be really helpful. Maybe it's something I should just go to reddit for. And if so feel free to tell me! Thanks again for this video and all the time you put into this and taking the time to respond to me
Broadly speaking, When an item is dragged, I call this custom definition, drag_placed (dragged drag_placed in the drag item).
In the definition, the first two lines just return back to the drag screen without doing anything else, so as long as you are actively dragging an item, the definition is waiting for you to drop the drag item into a droppable item. If you do not drop it onto a droppable item, then the definition does not do anything.
Once the drag item is dropped, it's storing two values: the first is the term "draggable", which is the name of the thing you are dragging (store.draggable = drags[0].drag_name).
In the second line, you're storing the name of the item you dropped in "droppable" by seeing what the drag item was moved to (store.droppable = drop.drag_name).
Then, it returns a value, True (return True).
How I use this in practice, is that I CALL a screen with the drag group (drag_sample 2), so when one of the items is dragged to one of the droppable items, the called screen disappears, because the definition drag_placed is returning a value, but not before it stores the two variable names for me.
Then, I use a little visual trickery to give the illusion of some permanence to the screen.
Now with those variables, I show a new screen, drag_sample3, which just shows the droppable items in their same positions, but with the draggable items removed. Then, I have some if statements that display elements based on the two newly stored values: store.draggable and store.droppable. I set an x-position value based on if they picked the left or right circle (droppable), and then I see what object was dragged (draggable), and then I only display that one object along the y axis of the circles, and use the x position value to center it on the left or right circle.
Then, I list out where the object is placed, by using our stored values to display their names - "The [draggable] was put in [droppable]".
ESSENTIALLY, all you need to know is that if you call a drag screen, you can use this code to get the name of the thing that was dragged, and the thing that was dropped, and then you can do whatever you want with that information - move them to a different part of your game, alter a value, or even bring them back to the drag/drop screen to do it again.
From there, you're limited by your imagination!
@@vimi okay that's really helpful, I'm gonna try and implement that to make sure I understand it. Thank you so much for providing such a thorough and patient answer, also. Love your videos, and have a great day!
My new drag performer name is Circle. 😂
Does this work if you build it on android?
I'm not at my home computer where I can test it, but I'm fairly certain you can
Day #1 of asking a tutorial on how to export a game from renpy
On your ren'py launcher, under the "Navigate Script" section, press the text that says "Build Distributions". It will bring you to a new page that lets you name the zip file it will build, as well as the name of the executable file inside. Press "Build", and it will upload a zip file to the folder where ren'py is located on your computer.
If you want to build your game for android or iOS, there are separate sections with their own distribution items listed there.
www.renpy.org/doc/html/quickstart.html#releasing-your-game
@@vimi Ended the streak as soon as you saw it but TSYM IVE BEEN WONDERING HOW TO EXPORT FOR SOMETIME THANKS!!
as of 2024, with Ren'Py 8.2, the if statement doesn't work because (for some reason), "draggable" and "droppable" are not defined. It's bizarre, it's like being forced to define the "play" code command.
anyway, this is the code that's not working:
if drag_placed.droppable == "Meteor Card":
$ xpos_var = 150
if draggable == "Fire":
show Fire:
xpos xpos_var ypos 460
Correct, "draggable" and "droppable" are not defined, because you have to define them yourself. That's what the code at the 3:18 is for.
You don't always want to necessarily define the names; instead of the function "drag_placed", you can replace it with anything else that does the associated action. So instead of those if statements you have there, you could call an action that instead just does the position changes and image calls you need. Way more efficient.
If you included the drag_placed code, and it's that text that isn't working, then replace the "drag_placed.droppable" with just "droppable".
I was thinking a dress-up game. Apparently people find them relaxing, so I thought I'd make one without the usual gender expectations.
OMG AND A CAT (or dog) PETTING MODE. Maybe lizards and fish too, if they like being pet? Idk, I'm solidly a cat person