Noob question - [if container is empty][end if] doesn't work

Am I understanding the [if] conditions correctly? Here’s my code:

An object called Bob is in the Storage Room. Bob is fixed in place. Bob is a closed and openable container. In Bob is one coin. Understand "skeleton" as Bob. The description of Bob is "A well-preserved skeleton all dressed up according to Jackie's tastes. [if Bob is closed and if one coin is inside Bob] You spot a shiny coin clenched firmly between his teeth. You'll have to OPEN the skeleton to get it.[end if]" 

I’ve tried [if Bob is empty] but obviously that doesn’t work, [if something is inside Bob], [if Bob has something inside it], [if a coin is inside Bob], etc. etc. etc. My bad fix is just to do [if Bob is closed] but that relies on the player not closing Bob and then also not re-examining him. It just feels a bit sloppy and I’m so sure there’s a solution out there.

“If something is inside Bob” should work.

An abbreviated test:

Bob is a container.

The description of Bob is "Container. [if something is inside Bob]Yes[else]No[end if]."

[if Bob is closed and a coin is inside Bob] works the way you initially wanted it. You needed to remove the second if for it to compile.

Inform doesn’t seem to understand one coin as referring to the coin. I think it sees one as a number instead of part of the name of the object (compared to two coins, etc.).

1 Like

To go back to your unspoken question:

Inform defines empty as an adjective for texts, rulebooks, lists, and other programming constructs – but not for containers or supporters. This surprises people on a regular basis.

You can define this easily, though:

Definition: a container is empty rather than non-empty if nothing is inside it.
Definition: a supporter is empty rather than non-empty if nothing is on it.
1 Like

Thank you so much for both answers! That makes a lot of sense. That also explains why I needed to redefine how I made drinks and subsequently empty glasses now

Ah, so it was that simple :sweat_smile: Thank you so much for the help!! That makes a lot of sense