How to split items in a inventory

Godot Version

4.3

Question

I’m trying to add a split function to my game but i can’t seem to figure out how to, there are also no youtube videos what are up to date for this.

In more detail of what i’m trying to do is, i’m trying to make it so when i right click an item in my inventory it splits half the amount, and while holding the item in my inventory i can place one at a time when i right click, so basically just like in minecraft.

I am quite new to gdscript so i hope someone with more knowledge and experience can help me.

Let me know if there’s any more information and or clarification needed!

This depends on your inventory implementation. Do you already have a inventory set up?

2 Likes

Sorry for the late reply, yes i do have an inventory system made, you can check my inventory code on my other post: Invalid access to property or key '...’ on base object of type dictionary

You can find all of most important/essential inventory scripts.

I’ll be hoping for your reply!

You probably have to add a method takeHalfStack() that reduces the amount to half and returns a copy of the object with the other half.
And add a insertSingleObject() that copys the current object with the amount of 1 and reduces the one you are holding by one