Help with coding a dual-state object

Hello everyone. First post. I’d like to ask for help solving a coding issue.

As an exercise, I’m working to implement Infocom’s Infidel in Inform 6. I’m coding up the cot, which can be folded or unfolded.

There seems to be two ways to do this: 1) create one object and use attributes to track its state (folded or unfolded) or 2) create two objects, a folded cot and an unfolded cot, switching them out (via “move” and “remove”) depending on the player’s actions.

If I use one object, the room description always displays, “You can see an army cot here” regardless of the cot’s state.

If I use two objects, the room description will correctly display either “You can see an army cot here” or “You can see a folded army cot here” depending upon the state.

However…

If I use two objects, “it” will refer to the one that was removed and not to the current object. Here’s an example:

x cot
It’s just an army cot.

fold it
Folded.

x cot
It’s just a folded army cot.

So far, so good, as long as I explicitly refer to “cot.”

But…

x cot
It’s just an army cot.

fold it
Folded.

x it
You can’t see “it” (the army cot) at the moment.

I hope I’ve described this well enough. Please let me know if you need more detail. Any advice would be greatly appreciated.

It’s easier to use one object.

You can use either the short_name property or the initial property to customize this. Or describe, but that’s a bit trickier. Any of these can be a routine rather than a fixed string.

EDIT: I got initial and describe backwards. Heh. Tells you how long it’s been since I did serious work on an I6 game.

initial is simpler to use; with describe you have to print an extra newline.

1 Like

short_name did the trick. Thank you for the quick reply!