Using knife with self action

Hi all, I’m really stuck on how to allow an object such as the ‘knife’ to be used to cut the player character, for example for a ritual.

[code]+knife: Thing ‘silver knife’ ‘silver knife’
“It gleams as if it has been polished recently.”

iobjFor(CutWith)
{
    verify() {}
    action()
    {
        
    }
    
}

;[/code]
What would I put within the action() {} bit of code to get this to work? This is the pseudocode:

If target is player
{
“You make a small cut on your palm and draw blood.”
‘silver knife’ becomes ‘bloody knife’
}

Any help would with this would be very much appreciated.

Welcome to the wonderful world of TADS 3! Feel free to post any questions you may have. Here’s some code that I think does what you’re seeking:

[code]+ me: Actor ‘me self’ ‘yourself’
dobjFor(CutWith) {
verify() {}
check() {}
action() {}
}
;

++ knife: Thing ‘knife dagger blade’ ‘knife’
"A <<isBloody ? ‘blood-smeared’ : ‘gleaming’>> silver dagger. "
isBloody = nil
iobjFor(CutWith) {
verify() {}
check() {
if (gDobj != me) failCheck ('You can’t cut {the dobj} with the knife. ');
else if (isBloody) failCheck ('Don’t you think cutting yourself once is enough? ');
}
action() {
"You make a small cut on your palm and draw blood. ";
isBloody = true;
cmdDict.addWord (knife, ‘bloody’, &adjective);
name = ‘bloody knife’;
}
}
;[/code]
the cmdDict.addWord() function is really useful in situations like this – you can learn about it by searching for cmdDict in “Learning T3”. Once you’ve used it, the player will be able to refer to the knife as “bloody knife”.

Oddly enough, the dobjFor(CutWith) has to have an empty action() statement, as the reportFailure macro is being called from there in the library code for the Thing class (from which Actor is derived).

This is exactly what I was looking for, thank you so much! :slight_smile: