
Important notice! This script is no longer updated to work with newer versions of Ren'Py. It does still work with Ren'Py 8.1.1 though. Over time as Ren'Py has changed, the script lost some functionality where saving and loading things within the script and possibly other things no longer work well. It was not feasible to keep updating it at this point as the code would have needed a large overhaul to work. Instead, I have two newer and better structured inventory scripts you may want to have a look at: Drag & Drop Inventory v.2 and Inventory with context menu.
A complete video-series of how to create a drag & drop inventory system in Ren'Py is now available on my Youtube channel! Check it out if you haven't already! It will fit well for point-and-click type of visual novel games.
It consists of 6 videos where we'll create an inventory at the bottom of the screen that can be opened and closed. Each of the inventory items has it's own overlay menu that triggers when you hover over the item, and allows you to choose if you want to inspect the item closer or drag the item around.

If you choose to drag the item, you can then combine it with another item in the inventory or in the environment by clicking with the mouse on the second item you want it combined with.

We also implement our own say screen that will make sure that no interactions can happen on buttons or items while the dialogue is showing. This will also ensure that the dialogue will work nicely together with the inventory functionality.

The artwork provided for this tutorial is made by me by either my own imagination or by using public domain images, usually vintage ones, that I have edited and/or combined in different ways. If you want to know more about the artwork, you can read the behind-the-scenes post available for paying patreons only.
You can download the complete script and artwork below for free, but if you're able to, I would appreciate if you considered joining my Patreon in any tier to show your support for as long as you can or am comfortable with.
Enjoy!
UPDATES
Important notice! This script is no longer updated to work with newer versions of Ren'Py. It does still work with Ren'Py 8.1.1 though. Over time as Ren'Py has changed, the script lost some functionality where saving and loading things within the script and possibly other things no longer work well. It was not feasible to keep updating it at this point as the code would have needed a large overhaul to work. Instead, I have two newer and better structured inventory scripts you may want to have a look at: Drag & Drop Inventory v.2 and Inventory with context menu.
The file has been updated (version 1.0.1) to work with Ren'Py version 8. Ren'Py has changed how float values work for positioning displayables which makes the overlay menu not showing correctly. Read the quoted comment below from part 6 of the series to learn more.
Link to video where I posted the comment: https://www.youtube.com/watch?v=5kI2PUELgsE&lc=Ugw4wRCEeG7hLzwtRPp4AaABAg.9d8sIfNNS549dboORG7kGU
"The reason for this seems to be how Ren'Py now handles positioning values.
Float values (decimal values: 0.5, 25.36 etc.) have been treated for a long time by Ren'Py "as a fraction of the size of the containing area" (quoted directly from the documentation). So for example, writing 1.0 as the xpos value will place the displayable at the right edge of the window, 0.5 would be in the middle and 0.0 is the left edge.
If one writes an integer value (ex: 10, 25 etc.) it is treated as pixel coordinates. However, one has been able to get away with, for some reason, to enter in a large value like 468.5 and it be treated as a pixel coordinate instead for a while now. But since the update to version 8, one cannot get away with this anymore, and it is treated as a fractional value instead.
So the reason why the overlay menu doesn't show on top of the second item is because its positioning values item.x and item.y contains float values instead of integers for the second item, and we have to typecast them to integers instead of floats for it to work."
Updated the script (version 1.0.2) to show how you can switch between different scenes without having environment items carry over from scene to scene. Please watch the tutorial video for this update to follow along with what has been changed and why. Watch it here: https://www.youtube.com/watch?v=gXfNHbSfnbo
The script has been updated (version 1.0.3) to fix an issue in the "repositionInventoryItems" function as reported on the last video in the series (switching scenes). The items wouldn't position themselves correctly in some circumstances.
That's because I had mistakenly written "inventory_sprites[-1].original_x = item.x" in the "if i == 0" statement, as well as inside the following else block. So the fixed code now looks like this inside the function:
for i, item in enumerate(inventory_sprites):
if i == 0:
item.x = inventory_first_slot_x
item.original_x = item.x
else:
item.x = (inventory_first_slot_x + inventory_slot_size[0] * i) + (inventory_slot_padding * i)
item.original_x = item.x
The inventoryArrow's function wasn't updating the 'original_x attribute' of the inventory sprites after being shifted to the left or right, resulting in that items would snap back into their old slots when being dropped. This has now been fixed in version 1.0.4.
Project files attached below (version 1.0.4).
When saving while being in one scene, then loading the game back up and going into another scene, the items would carry over. This has been fixed by adding "renpy.retain_after_load()" as the last thing in each scene setup label inside the if statement "if item not in environment_items_deleted:". You can see this by going to line 471 and 518 in the main script.
Project files attached below (version 1.0.5).
Sara
2023-02-20 12:50:09 +0000 UTCNampot
2023-02-20 12:13:39 +0000 UTCSara
2022-11-07 09:52:46 +0000 UTCBladeGrip
2022-11-05 19:52:43 +0000 UTC