I’m new to Inform (very experienced in python and various other languages). I’ve been scouring the forums for the past three hours. What I’m trying to do is essentially reference a generic object (that is, a generic instance of a kind). Here’s a minimal example:
A bed is a kind of supporter. A bed is always fixed in place. A marble is a kind of thing. My Room is a room. In My Room is a bed. It supports a marble. Your Room is east of My Room. In Your Room is a bed. It supports a marble. There is a gold key. After jumping in Your Room: move the gold key to [entry 1 of the list of beds which are in Your Room].
What’s curious about this is how “It” refers to the generic object when I say “It supports a marble.” There’s some sort of temporary reference here. However, that same “It” seems to be gone for good afterwards. Is there a correct, canonical way to specify a particular instance of a generic object within a phrase at runtime, so that you can do something with it?
The other approach would be to give these generic objects identifiers. Something like this:
A bed is a kind of supporter. A bed is always fixed in place. The printed name of a bed is usually "bed". My Room is a room. A bed_01 is a bed in My Room. It has description "This is my bed." Your Room is east of My Room. A bed_02 is a bed in Your Room. It has description "This is your bed." Understand the printed name property as describing a thing.
However, this approach means keeping track of dummy variables and makes the code a lot less elegant. It also introduces confusion about grouping items (see this for a related discussion). Another hint that this is wrong is that the phrase “Understand the printed name property as describing a thing.” doesn’t show up anywhere in the documentation. So… this doesn’t seem like the Right Way to do it, either.
Ultimately, it looks like the right approach would be to declare generic objects and then have some way to refer to them later, as I had earlier: “move the gold key to [entry 1 of the list of beds which are in Your Room]”
Although even that’s ugly because of the lack of assertion. Something even more ghastly would be:
thething is an object that varies. After jumping in Your Room: let L be a list of objects; now L is [the list of beds in Your Room]; assert [the number of entries in L] is 1; now thething is [entry 1 of L]; move the key to thething;
It’s clear that I’m completely on the wrong track. Anyone able to point me in the right direction?