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

The room is empty.

There is a pebble here.

>x stone
The stone is small and round.

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.


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.]