Alway Worn Objects - TADS3

My actor has some ‘always worn’ objects. when I test them by trying to drop them, I get the following message:

“First trying to take off the the khakis”

Then I’m told that I can’t take them off.

Is there any way to stop the first line from displaying?

Here’s a sample of my code:

++khakis: Wearable ‘pair/kahki/khakis/shorts’ ‘pair of khaki shorts’
“You are wearing a pair of rugged knee-length khaki shorts with very handy
pockets.”
wornBy = me
isPlural=nil
dobjFor(Doff){
check(){
failCheck (‘This is not the time nor place to start undressing.’);
}}
;

I’ve tried using the ‘AlwaysWorn’ approach but then I get compile errors.

The easiest way is simply to redirect the drop action to the doff one.

++ khakis: Wearable 'rugged pair/kahki/khaki*kahkis*khakis*shorts' 'khaki shorts'
	"You are wearing a pair of rugged knee-length khaki shorts with very handy
	pockets."
	wornBy = me
	isPlural = true
	dobjFor(Doff) {
		check() {
			failCheck ('This is not the time nor place to start undressing.');
		}
	} 
	dobjFor(Drop) asDobjFor(Doff)
;

The vocabWords property - that part with the slashes and asterisks - took me awhile to understand. It breaks down like this.

  • A list of adjectives, separated by spaces
  • A list of singular nouns, started with a space, separated by slashes
  • A list of plural nouns, started with an asterisk, separated by asterisks

Not sure why you set isPlural to nil. If you set it to true, and leave the plural stuff out of the actual name, then it should show up correctly in listings as “some khaki shorts.”

The AlwaysWorn class from RTDD game is not a standard class provided by the Adv3 library, but it’s a new class defined in the game source code (in the mods.t file). If you want to use it, you should copy the following code into your game. That’s only FYI as it doesn’t solve your problem. But you can add dobjFor(Drop) asDobjFor(Doff) into it as bcressey suggests.

/*
 *   A class for clothing worn by the player character, and which we can't
 *   take off.  We use this for the PC's constant complement of clothes;
 *   there's no reason to remove these.
 */
class AlwaysWorn: Wearable
    wornBy = me
    dobjFor(Doff)
    {
        check()
        {
            cannotDoffMsg;
            exit;
        }
    }
    cannotDoffMsg = "You really don't have any reason to get
        undressed right now. "

    /* exclude these from DROP ALL and DOFF ALL */
    hideFromAll(action)
    {
        return action.ofKind(DropAction)
            || action.ofKind(DoffAction)
            || action.ofKind(PutInAction)
            || inherited(action);
    }
;

RonG, please always post your code between code tags.

Thanks again for all the quick advice. I downloaded a piece of code named ‘custom.t’ which looks like it will be helpful.

I used plural because it sounds and looks more natural to use ‘the pair of shorts are…’ rather than ‘the pair of shorts is…’

What’s wrong with this picture?

/*******************************************************************************

  • Always worn. A class of objects that the player cannot take off. *
    *******************************************************************************/

class AlwaysWorn: Wearable
wornBy=me
dobjFor(Doff)
{
check()
{
cannotDoffMsg;
exit;
}
}
cannotDoffMsg = “You really should be wearing this and have no reason to get rid
of it.”

/* Exclude these from Drop All and DOFF All. */

hideFromAll(action)
{
return action.ofKind(DropAction)
||action.ofKind(DoffAction)
||action.ofKind(PutInAction)
||inherited(action);
}
;

/Next batch of code**************/

replace VerbRule(Doff)
(‘doff’|‘drop’)dobjList
:smiley:offAction
verbPhrase=‘doff/doffing(what)’
;

I am using the above two batches of code. The first batch was posted to me by TOMASB. The second, small batch is by me.

I have two AlwaysWorn objects. If I use “Doff” to drop the objects, it works fine and the objects are not dropped. If I use “Drop” to drop the objects then I get a run-time error

Any Ideas :question:

RonG

[code]
Your code goes here.
[/code]

That’s how you write code tags in the forum :slight_smile:

Don’t add drop as a synonym for doff at the verb level. Conceptually you are saying that in your game, “drop X” is always equivalent to “remove X”. This will break dropping items in the normal course of inventory management.

You should be using “dobjFor(Drop) asDobjFor(Doff)” in your AlwaysWorn class.

Many thanks. That code works well now.

RonG