Help with dobjfor

So i have a container object, a venus flytrap.

the “blue key” is in it’s mouth. I want to set it up so that you can only take the key if you give the flytrap the steak object. if the steak is not in the flytrap, i want it to display a message, and not take the key.

can anyone help?

As far as I know, there’s no way for the player to get the key without ‘taking’ it, either explicitly or implicitly, so you just need to add a check for taking the key.

There are three parts to an action in T3: verify, check and action. Since the take verb defines its own stuff for each of these parts, we just need to override the check part, calling failCheck if the situation doesn’t meet our criteria.

This should sort you:

[code]+Steak: Thing ‘steak’ ‘steak’
"A juicy steak that would satisfy any carnivore. "
;

+VenusFlyTrap: Container ‘venus fly trap’ ‘venus fly trap’
"What a vicious set of jaws. They could probably take your whole hand off. "
;

++BlueKey: Thing ‘blue key’ ‘blue key’
"You suspect it opens a blue door somewhere. "
dobjFor(Take)
{
check()
{
if(Steak.location!=VenusFlyTrap)
{
failCheck('Yeah, not putting your hand in those jaws.
Perhaps if you could find something else for them to chew on? ');
}
}
}
;[/code]
You might also like to add similar handling for the steak, so you can’t take it back from the plant.

Thinking about it, though, it might be nice to implement the Venus Fly Trap as a character, since I think players may end up thinking of it that way. In that case, you just need to configure the method that defines when you can take stuff from it:

[code]+Steak: Thing ‘steak’ ‘steak’
"A juicy steak that would satisfy any carnivore. "
;

+VenusFlyTrap: Person ‘venus fly trap’ ‘venus fly trap’
"What a vicious set of jaws. They could probably take your whole hand off. "
checkTakeFromInventory (actor, obj)
{
if(obj==BlueKey)
{
if(Steak.location!=self)
{
"The fly trap grips the key tightly in its vicious jaws. ";
exit; //this makes taking the object fail
}
else
"You carefully extract the key from the fly trap. ";
}
else if (obj==Steak)
{
"The fly trap is busy chewing on the steak. ";
exit;
}
}
iobjFor(PutIn) remapTo(GiveTo,DirectObject,self)
;

++ GiveTopic @Steak
topicResponse
{
"The fly trap chomps on the steak greedily. ";
Steak.moveInto(VenusFlyTrap);
}
;

++BlueKey: Thing ‘blue key’ ‘blue key’
"You suspect it opens a blue door somewhere. "
;[/code]
You’d also want to change the way its inventory is described (see this article) and give it some default topics with witty responses to attempts to engage it in conversation.

Thanks a million times. This was unbelievably helpful.