Checking to see whether the apple has been picked up

Man, today is proving hard work with Inform.

I want to see whether the apple has been picked up by the player. If it hasn’t then I want to show another line of description. I’ve used this elsewhere in the game and works fine. However for this bit, it just won’t work.

I’m using…

an apple is a kind of thing.
[if the player does not enclose the apple]There are apples lying all over the grass; some are half rotten, some eaten by birds, but there’s one by your feet that looks to be just right.".

I get…

[i]In the sentence ‘“Various fruit trees line up like s […] feet that looks to be just right.”’ , I was expecting to read a condition, but instead found some text that I couldn’t understand - ‘player does not enclose the apple’.[/]

I’m using the same line previously with another object in another room and it works fine.

Any ideas?

Olly

Inform doesn’t understand what you mean by “the apple,” since apple is a kind rather than a specific object. Often Inform interprets this to mean “an apple,” which often leads to difficult-to-diagnose bugs, but this time it seems to have broken. (Also, from the text you pasted, it kind of seems like there might be a punctuation later that causes a couple of lines to run together.)

If you want to refer to a thing in its description (or in any other property it has), you can use “the item described,” so you can try this:

an apple is a kind of thing. "[if the player does not enclose the item described]There are apples lying all over the grass; some are half rotten, some eaten by birds, but there's one by your feet that looks to be just right.".

However, I think this probably winds up setting the initial appearance property rather than the description. Also, this leaves you with no text when the player does enclose the example. So you can explicitly set it to the description, and provide more text:

an apple is a kind of thing. The description of an apple is usually "[if the player does not enclose the item described]There are apples lying all over the grass; some are half rotten, some eaten by birds, but there's one by your feet that looks to be just right[otherwise]A firm, juicy apple[end if].".

“Usually” works because we’re talking about a kind–this lets you set the description of a specific apple to something else, if you so desire.

By the way, I haven’t tested this code out myself, so it’s not guaranteed.

Thanks. Blown my mind.

I feel like I’m taking two steps backwards each time I try to move forward.

I’ll give it a go tomorrow.

“The item described” is unfortunately not described very well in the documentation at all–you kind of have to pick up what it does from examples (or ask someone).

I’d also say, as a design thing, that you probably want to have some sort of scenery-apple that remains whenever the player has taken the apple from an orchard room, so it doesn’t seem like all the apples have gone away once the player has taken the good one.