T3: Handing Something Over

I know how to use a GiveTopic to transfer an item from the PC to an NPC. But what if, instead of ‘give bob the ruby’, the player types ‘bob, take the ruby’ while the player is carrying the ruby? I’ve added TCommand.t to my project, which handles the action … right up to the point where the object is supposed to change hands. Then it fails:

I’ve been searching around in the LRM and other docs to try to find the method that is checked to determine whether an Actor is willing to part with something in inventory – and I haven’t been able to find it. I’m sure it’s something simple. Help would be appreciated.

Never mind. I figured out an easy workaround.

Here is the adv3 way to do this without any workarounds: override Actor.checkTakeFromInventory(actor, obj). The default implementation won’t allow any object to be taken:

/*
 *   Check to see if we want to allow another actor to take something
 *   from my inventory.  By default, we won't allow it - we'll always
 *   fail the command.  
 */
checkTakeFromInventory(actor, obj)
{
    /* don't allow it - show an error and terminate the command */
    mainReport(&willNotLetGoMsg, self, obj);
    exit;
}

‘actor’ is the Actor trying to take the object from the ‘self’ Actor.