GetLastDisturbed()

Determine who last disturbed the inventory of an object or creature.

object GetLastDisturbed();

Description

Returns the last object to disturb the inventory of an object or creature. Returns OBJECT_INVALID if the inventory is undistrubed, or if the object has no inventory.

In this function, the inventory is "disturbed" the moment its contents are changed by either removing or adding an item. Simply examining the inventory's contents does not cause a disturbance. Also, it does not wait until the inventory is closed; as soon as something is added or taken away, GetLastDisturbed() will point to the player or creature.



Remarks

This function must be called from an event script owned by the object whose inventory is being tested.


Known Bugs

It has been previously noted that the event OnDisturbed does not fire when the item being disturbed is gold. There’s still something odd going on with that function. I made this little script and put OnDisturbed of a container:

void main()
{
object oPC=GetLastDisturbed();

object oDisturb=GetInventoryDisturbItem();

SendMessageToPC(oPC, "this: "+GetName(oDisturb));
}

When I put gold into the container, I get a message telling me “this: Gold piece”. So it does fire for gold. When I take it back from the container, I get the message “this:”
I tested it, and when removing gold from a container, GetInventoryDisturbItem() returns OBJECT_INVALID.

Also, there’s a bug with stackable items. If a stackable item is added to another stack in either the givers or receivers inventory, the OnDisturbed event never fires (except for gold pieces, apparently).


Version

1.30

See Also

functions: GetInventoryDisturbItem | GetLastHostileActor | GetLastOpenedBy
categories: Inventory Functions


 author: Jason Harris, editor: Lilac Soul, additional contributor(s): Lilac Soul