How to rename an object according to player input? [TADS 3]

Ok, given an object like

+ stone: Thing 'small round stone/pebble' 'pebble' "The pebble is small and round."
;

what would I need to edit, or change, to rename the object according to player input? Such as

>l
The room is empty.

There is a pebble here.

>x stone
The stone is small and round.

>l
The room is empty.

There is a stone here.

Is this even at all possible in TADS 3?

Iā€™m using the following solution in my current game:

stone: Thing 'stone/pebble' '<<currentName>>'
  "The <<currentName>> is small and round. "
  currentName = 'stone'

  matchNameCommon(origTokens, adjustedTokens) {
    currentName = toString(origTokens[1][1]);
    return self;
  }
;
You see a stone here.

>x stone
The stone is small and round.

>x pebble
The pebble is small and round.

>l

You see a pebble here.

Hey Collin, I was wondering if you were still working in TADS at all! Have you checked your solution to see what happens if the player just refers to the object by one of its adjectives? Is it necessary to check and only make the change if the token is associated with the &noun property?

myrkraverk, were you thinking of using this mechanism globally throughout your game, or just in conjunction with selected objects? It seems like youā€™d need some kind of screening process if it was used widespread, because frequently itā€™s desirable to give objects a lot of synonyms in their vocab, and not all of the alternatives that allow a player to identify an object would sound equally well (or even congruous) being used in parser messages about that object.

I am thinking about it for a certain class of objects, so probably a lot, but not absolutely everything.

I am hoping Iā€™ll be able to create a subclass for my objects that behave this way.

Right now Iā€™m only in the first stages of brainstorming, so creating some concept descriptions and behaviours and thinking about the setting, characters, and story for the game itself.

So far I like TADS 3 [and thereā€™s no IF language I like more.], but Iā€™m not committed to any specific system yet.

I think TADS 3 is a great language! Hopefully you stick with it! Iā€™ve been working on a pretty large game for about a year and a half now.
As far as your mechanism, do you think you will need the code to do any checks before changing the ā€˜nameā€™ property of the object, or do you think you would just only give vocab to the objects where any of the words would be suitable to show up as a reference to that object?

Collin, the concept works, but needs some refinement. When I add adjectives, I get

>x small round stone
The small is small and round.

I can fix this myself; thank you.

John, right now I donā€™t know how many checks Iā€™ll need to make, because Iā€™m still just fleshing out the concepts. Now that I know I can do this, I can sketch up some prototypes and figure out where I want to go with this.

currentName = toString(origTokens.sublist(-1, 1)[1][1]);

sorts out the adjective problem for me, if you havenā€™t got it working yet.

edit: thereā€™s still the problem of addressing the object by an adjective alone, but Iā€™ve never been a fan of catering to that feature anyway :slight_smile:

Adjectives alone donā€™t work. In fact adjectives at all donā€™t work with that code (see fix in the comment above).

Yeah, Iā€™m back at my game after all those months of being busy with other things. Glad to see that youā€™re still around :slight_smile: Howā€™s your game coming along?

I wonder if a solution could be to add a property to any subclasses that use this name-change-based-on-player-input. The property could be a list of tokens that are acceptable as name changes for the object. If the playerā€™s latest reference to the object didnā€™t include one of those tokens, no change is made to the name.
It seems also that the normal ā€˜nameā€™ property could be used, instead of the additional ā€˜currentNameā€™ property.

In my case I need to keep the ā€˜defaultā€™ name around, but otherwise yeah - you could just use the normal name property.
Your idea with the token list sounds good :+1:

This solution will work, but be careful. You donā€™t want to end up in a situation where you get things like ā€œyou see a pebble and a pebble hereā€ because ā€œsmall stoneā€ got renamed to ā€œpebble.ā€

Another issue is that renaming an object might confuse some players. Just because I referred to the pebble as ā€œstoneā€ I donā€™t actually expect the name the game uses to change! A notification might be helpful here. Like [OK, from now on I will refer to the pebble as "stone" instead.]

2 Likes