Changing inventory description of items depending on states

I am working on a project where the player can, with duct tape, attach two items together.

So, if the players inventory is:
a roll of duct tape
a rabbit
a pair of antlers
And the player tapes the antlers to the rabbit, how can I get the inventory to read
a roll of duct tape
a rabbit with a pair of antlers taped on?

Thanks in advance.

Can you show us the code that you’re using to attach the two objects together when the player types TAPE ANTLERS TO RABBIT (or whatever your syntax is)?

There are a number of different ways to do it, depending on how you’re doing the attaching and in what circumstances you want to display the additional text.

Assuming that you’re attaching the antlers to the rabbit via something like now the antlers are part of the rabbit, then you could:

The printed name of the rabbit is "[if antlers is part of the rabbit]rabbit with a pair of antlers taped on[otherwise]rabbit".

Or indeed:

The printed name of the rabbit is "rabbit[if antlers is part of the rabbit] with a pair of antlers taped on".

This will display your adjusted name in every context where Inform prints the name of the rabbit. Alternatively:

Rule for printing inventory details for the rabbit when the antlers are part of the rabbit:
	say " (with a pair of antlers taped on)".

This will print the amendment only in the inventory listing, not other contexts (and notably not in room descriptions either – if you want that, you need another rule either in addition or instead for printing room description details).

Note that in either of these cases you should similarly update the description with conditional text, for consistency.

This can be turned into a more general system if there’s lots of things that the player will be taping to other things.

1 Like

Another alternative, which rolls everything up into one rule that works both for room description and inventory details, but not in other contexts:

After printing the name of the rabbit
  while looking or taking inventory
  when the antlers are part of the rabbit:
	say " (with a pair of antlers taped on)".

If you don’t want/anticipate the player removing the antlers again, you could also do:

Carry out taping the antlers to the rabbit:
    now the printed name of the rabbit is "rabbit (with antlers taped on)";
    now the antlers are nowhere.