SamSuka
__ess__
__ess__

patreon


[IN THE WORKS] Drag & Drop Inventory V2

Hello everyone! Hope you're doing good in the world. ⭐😊

So lately I decided to give the whole drag and drop inventory a new go, since the old one stopped working for newer versions of Ren'Py, and I felt like I could make it a bit better this time around as well. 

It's not complete yet, and I'm still testing and tinkering to try to make sure everything works well. So far it's looking good. 😁 It will most likely go into the Voter tier, and might get some extensions into the higher tiers with more features I'm thinking of adding as well. But we'll see.

Below you can read more about how I have decided to develop it and some of the "quirks" of it. When it's uploaded I will explain how to use it more detailed.

Drag & Drop system

This time, I wanted to try using the drag and drop system which I knew was going to be presenting a challenge due to how the drag system works in Ren'Py.

If you have tinkered with the old inventory, you would have seen that we used different screens for the inventory and the scenes. That meant we could keep them separate which, to some, would probably be a little easier to manage and organize.

The thing with the drag and drop system is that all drags that should be able to interact with each other (such as dropping one onto another) need to be in the same drag group. That means we can't separate different scenes into different screens, but both the environment items and the inventory items needs to be in one screen under one and the same drag group.

So, long story short, to solve this I decided to make a screen that would represent both a scene and the inventory. It works by making sure the background for this screen automatically switches to different images based on a variable "current_scene", which contains the name of the scene that should currently display.

For the items in the environment, they go into the drag group. Here we need to add each drag manually by adding image, position, and actions to run depending on what we're doing with the drag.

Ultimately, to try to keep down the code in the screen, I was hoping to be able to skip adding each drag manually as I was also thinking about different potential use-cases this script might have (by you patrons). For someone who's wanting to make a point-and-click game with, for example, 20 scenes with maybe 5-10 environment items each, it wont take long until the group will suddenly have quite a lot of drags in them, which might make the code in the screen a bit hard to navigate in the end.

For that I thought I could probably use environment item images that take up the entire screen with transparent areas, and use the "focus_mask" property to make only the opaque pixels intractable. Then one could have a list of images which would be looped through in the screen, and thus added "automatically". Then there would be no need to position each individual item.

The problem I encountered when testing this, is that the "focus_mask" property simply don't work well with the drag and drop system. So dragging and dropping stops working completely which is a bummer. I also found renpytom talk about this on github when someone else asked about it, and doesn't look like it will be a possibility in the future either (most likely for good reasons though).

In the end I decided to just manually write each drag as there are only a few in the example code, and I also know some people will just want to have a smaller game using the drag and drop inventory with less drags so this will work well for that.

But another possible solution is to of course, make a list or dictionary with each item's positions together with the list of image names and then loop through those to add them. That would make the screen a little less bloated (will see about adding a proper code example later when the script is uploaded).

For the inventory items and slots specifically, I used a for loop as the item's sizes are all the same, and the locations of the items are simply based on math. The inventory background and arrows are added manually.

Small example code:

I think that's about all I wanted to say about it for now.

Thanks for reading. ⭐


Comments

Hi Lia! I thank you very much for the time you have pledged and welcome you back if you should chose to and are able to. Either way, stay safe and well you too, and thank you for your kind words. I appreciate it. 😊

Sara

Hi, Ess! I just wanted to tell you thank you for all your amazing scripts!! I'm unfortunately in a tight spot with money, so I'm cutting down on expenses, thus stopping my pledge here.... Hopefully my situation will improve soon that I can come back, but until then stay safe and well! Keep on coding!

Lia Teapot

This is a very fun concept. I like your idea for the inventory screen and it works well at the bottom. The button for expansion flows well and having it behind the text works too. I can see a lot of possibilities for storytelling with this. Great job so far.

Akouo Studios


More Creators