Basically just make an item based off a tome (ie: tome of power, tome of agility, tome of strength, etc.)
Then write a trigger so that if the unit aquires the item, and has none of item 'x' in their inventory, and they have an empty slot in their inventory, it gives them item 'x'.
If the unit has item 'x' then increase number of charges by '1'
lol,you can´t do that coz hero will not be able to acquire an item with full inventory so trigger will not run -.-
anyway i think you should use MortAr-´s suggestion,
but i think that it may only work for picking up items on ground,not buying them
if you use my suggestion you should also create variables (if you have a lot of items
variable type: item type
DUMMY ITEM [1] = POTION OF MANA
DUMMY ITEM [2] = POTION OF HEALING
REAL ITEM [1] = POTION OF MANA
REAL ITEM [2] = POTION OF HEALING
> unit acquires an item
for each integer from 1 to 2 do actions
IF
item being manipulated equal to DUMMY ITEM [Integer A]
THAN
create REAL ITEM [Integer A] and give it to (triggering unit)
> unit loses an item
for each integer from 1 to 2 do actions
IF
item being manipulated equal to REAL ITEM [Integer A]
THAN
------------------------------------------
remove item being manipulated
OR
set life of item being manipulated to 0
OR
hide item being manipulated and remove after real is created
------------------------------------------
create DUMMY ITEM [Integer A] at position of item being manipuleted