loftar wrote:I could, theoretically, unequip the current item, the try and equip the new item, and then, if that fails, reequip the old item, but the downsides to that option are that 1) the old item would still suffer the effects on unequipping (such as a torch being put out) and 2) it is unclear how to handle the old item refusing to reequip (such as would be the case with bloated leeches).
If an item is on the cursor and you click an inventory slot, call the check to see if that item can be equipped but pass a flag to that function so that it ignores the "is the slot free" check.
If that is successful (so the item CAN be equipped), then item A is unequipped (and placed in some kind of temp program storage), item B is equipped and then item A is put on the cursor.
Issue: What if you're equipping a two-handed item (pickaxe) and have both hands already equipped (an axe and saw)? Well...
sabinati wrote:could you make the old item go to a free space in inventory, and failing that...
... refuse to do the swap.