Questions about item use

Discussions, Solutions & How To with Inventory
Posts: 5
Joined: 23 Jan 2013, 18:45

Questions about item use

Postby AsteroZoha » 27 Jan 2013, 20:37

Hello again,

I want to know if it is possible to do the following scenario :

==> When the user right-click on an equippable object in the bag, if they have already something equiped he can't swap them (he have to remove the equipped item first by right clicking it ).

I also want to not allow the drag and drop to equip items on the character (but only allow it for dropping item).

So the question is how can I remove the swapping system + the drag n' drop character screen/bag screen.

User avatar
Site Admin
Posts: 106
Joined: 07 Aug 2009, 14:54
Location: London, UK

Re: Questions about item use

Postby Adam » 28 Jan 2013, 14:07

To check against swapping an item, you would need to check to see if the slot were empty, and if not, fail.

Try this as a first (untested) suggestion.

The line where the Rt-Clicked item is loaded, I believe in JS it should be line 509:

Code: Select all

<509>      success = EquipItem (thisInventoryItem, l);

This should call the overloaded method that takes the slot into consideration.

In the properly overloaded function:

Code: Select all

function EquipItem (thisItem : InventoryItem, thisItemIndex : int) will notice that the first check is to see if the slot is empty. If it's empty, then it will simply fill it and remove the item from the inventory list. If it's not empty, then the next loop will be to swap the two items.

You can choose to NOT do this.

Simply comment out the second loop, and this will only fill the slot if it's empty.

Give it a test.


Now to remove the drag and drop functionality? That will be moderate surgery. The base assumption of the system is that you can drag & drop or click to move things around.

I would not simply cut off dragging and dropping, as you'd want to remove things by dragging them out of bags or off the character, no?

It sounds like you also want to disable dragging onto the bags as well? Is that true?

You can look at functions like "AddItem" and look for "dragItem.draggedItem", but you'll need to be moderately careful unstitching this...

If you don't get this working, can you tell me specifically what you want to be able to drag & drop and what you don't?

Return to “Inventory (for Unity Gui)”

Who is online

Users browsing this forum: No registered users and 1 guest