Replies: 2 comments 3 replies
-
In the current version - no, not directly. But you can probably find a workaround, something similar to what you described in this discussion. With that said, I'm currently working on item slots that can "own" the items (#130). That way the items would be stored inside the slot directly and there would be no need for an inventory at all. |
Beta Was this translation helpful? Give feedback.
-
Quick follow up on me trying to modify gloot to implement something like this. I can move items in and out of an item's inventory, close the inventory, change an item's slot, it will all be saved. If someone, one day, wants to do the same thing and/or improve it (I am not very good at godoting), here is what I did : First I made a InventoriesData singleton, which only contains an initially empty dictionnary variable called GlobalInventories. There is also a PlayerData singleton with a player_inventory dictionnary. This is specific to my game and this dictionnary contains itself dictionnaries where the data of the multiple inventory slots on the left are stored. Not ideal, I know, but couldn't think of a better way I then edited the default inventory_item.gd in gloot's files (I wanted to create a custom item class but I did not manage to make the protoset use another item class, so I edited the original script) to add these lines : Code
as you see, I use a boolean item property "is_container". It is not required on usual items but you must add it to your items that should have an inventory. You must also add a "container_width" int and a "container_height" int. Then it is just a matter of detecting if an item is a container, if yes retrieve its inventory data from the GlobalInventories singleton using its "inventory_id" property, and instancing a CtrlInventory UI linked to the inventory automatically created by the item when it is instanced I also added a line in inventory.gd under can_add_item so that you cannot store an object in itself : Code
I noticed that with that method it creates lots of empty dictionnaries in GlobalInventories. I searched why and from what I understand GLoot seems to be creating some sort of "proxy" item before replacing it by the "real" item with its saved properties when I deserialize my dictionnary, and so as this proxy item does not have a property "inventory_id" yet, it creates a new empty one, and when the proxy is replaced by the real item, we can interact with the items saved and all seem normal, but the dictionnary keeps these empty inventories that point to nowhere and it keeps adding them up. Not sure if this is due to my code or to GLoot's code ? I also noticed that when I am transfering an item from an item with an inventory to my equipment slots, the item preview disappears when I'm dragging it, but the item appears in the destination inventory when I drop it, same thing I'm not sure why it does it ps : Peter would you have a discord account or somewhere I could send you messages without bothering you ? Sometimes I'm like "hey I'd like to ask how this thing works or how it does this" but often it's too small or specific to make a post / comment about it here |
Beta Was this translation helpful? Give feedback.
-
Is there a way to create an item that have itself its own inventory ? I'm working on a system where the player has no "global inventory", and their inventory slots are tied to the clothes / bags they have equipped. Is this currently possible with gloot ? If not it's a suggestion then (:
thanks for your work on the addon, it is a great timesaver !
Beta Was this translation helpful? Give feedback.
All reactions