# Total newbie asks Inform 7 questions

Hi everybody! I’ve got experience with Twine and Adventuron, but today I decided to start learning Inform 7. I’ve been reading through the Documentation and come up with the following code for a trial one-room puzzle game:

``````The Mysterious Place is a room. "You are in a darkened room with no distinguishable features. You have no memory of this place."

The small table is a supporter in the Mysterious Place. The description is "It is a round-top table made of some dark wood which comes up to your knees."

The box of playing cards is on the small table. It is a container. It is closed and openable.  The description is "It is a standard red, blue, and white boxed deck of cards with a 'Bicycle' logo printed on it. The top flap is worn from use."

The One of Hearts is in the box of playing cards.  The indefinite article of the One of Hearts is "a".
The Two of Hearts is in the box of playing cards.
The Three of Hearts is in the box of playing cards.
The One of Spades is in the box of playing cards

The singed note is on the small table. The description is "The note reads: 'Riddle here.'"

The roaring fireplace is in the Mysterious Place. The fireplace is fixed in place. The fireplace is an open container. The description is "It is a brick fireplace. A fire dances inside it."

Understand "fire" as fireplace.

The incinerated husk is in the Mysterious Place. The description is "A discomfiting sight, indeed: on the opposite side of the room from the fireplace is a blackened husk which was, at one point, a living cat."

say "As if by a magic force, the husk refuses to budge from the ground.";

Instead of inserting something into the fireplace:
If something is the box of playing cards:
Say "You'd better not.";
Else if something is the One of Hearts:
Say "You throw the One of Hearts into the fireplace. The fire burns a vibrant purple as it devours the card."
Now the One of Hearts is nowhere;
``````

I’m trying to prevent the player from throwing the whole deck of cards into the fire. I’m also trying to make it so that the card is removed from play once it’s thrown in the fire. However, here’s what actually happens:

``````>take box
Taken.

>open box
You open the box of playing cards, revealing a One of Hearts, a Two of Hearts, a Three of Hearts and an One of Spades.

>take one of hearts from box
(the One of Hearts from the box of playing cards)
Taken.

>throw one of hearts into the fire
(the One of Hearts into the roaring fireplace)
You'd better not.

>inv
You are carrying:
a One of Hearts
a box of playing cards (open)
a Two of Hearts
a Three of Hearts
``````

Is there something I’m missing about why the One of Hearts is being identified as the box of playing cards? And when I remove the first “if” statement and just have the line about the One of Hearts, it doesn’t actually go out of the player’s inventory.

Any help is appreciated!

2 Likes

Welcome to Inform 7! I hope you enjoy it as much as I do.

In this case, the preamble “instead of inserting something into the fireplace” is actionable without clarification: probably anything inserted into the fireplace will get the “you’d better not” message (e: looking closer, it’s not this, it’s the token). Also, since “something” is a built-in token, the box is indeed “something” in all cases.

Something close to your phrasing would be:

``````Instead of inserting into the fireplace:
If the noun is the box of playing cards:
Say "You'd better not.";
Else if the noun is the One of Hearts:
Say "You throw the One of Hearts into the fireplace. The fire burns a vibrant purple as it devours the card.";
Now the One of Hearts is nowhere;
``````

My advice would be to break them up, though, just to keep things readable.

``````instead of inserting the box of playing cards into the fireplace:
Say "You'd better not.";

instead of inserting the One of Hearts into the fireplace:
say "You throw the One of Hearts into the fireplace. The fire burns a vibrant purple as it devours the card.";
now the One of Hearts is nowhere;
``````
4 Likes

OK, thank you so much! That’s very helpful.

3 Likes

A question: if I want to have all 52 cards in the deck, and I want, say, half of them to do one thing and half of them to do another, how do I code that without having 52 unique instances of “instead”?

3 Likes

Easiest way is to make two different kinds:

``````A red card is a kind of thing.  A black card is a kind of thing.

The Jack of Hearts is a red card in the box of playing cards.  The Queen of Spades is a black card in the box of playing cards.

Instead of inserting a red card into something:
Say "Red!"

Instead of inserting a black card into something:
Say "Black!"
``````

Generating 52 cards one by one might be a little annoying, though, and there might be easier ways to do that – can you say a little more about how you want this to work?

3 Likes

Sure!

I’m basically remaking a simple D&D puzzle with inform. In the puzzle, you have a deck of cards, and you solve a riddle to learn that you must throw all of the HEARTS into the fireplace to succeed.

``````A heart is a kind of thing.
A spade is a kind of thing.

The One of Hearts is in the box of playing cards.  The indefinite article of the One of Hearts is "a". The One of Hearts is a heart.
The Two of Hearts is in the box of playing cards. The Two of Hearts is a heart.
The Three of Hearts is in the box of playing cards. The Three of Hearts is a heart.
The One of Spades is in the box of playing cards. The indefinite article of the One of Spades is "a". The One of Spades is a spade.
``````

The specific problem I’m having is when I go to Instead/After:

``````After inserting a a heart into the fireplace:
Say "You throw the [the noun] into the fireplace. The fire burns a vibrant purple as it devours the card.";
Move the noun to nowhere;
``````

It’s the “Move the noun to nowhere” that I feel like should work, but doesn’t at all. Is there a way to have Inform recognize that I want to move the heart that was inserted into the fireplace to nowhere without specifying a single card?

I’m less concerned with the actual number of cards. I don’t need 52 for this example. I’d just love to know what syntax I’m not understanding to have Inform make sense of what I want.

3 Likes

Try “now the noun is nowhere” (you also have two "a"s before “heart” in the rule preamble FYI). “Nowhere” is kind of a special non-place, so “move” might not work the way you think it should.

2 Likes

OK, that did it! I think I was getting tripped up between using “the noun” vs. “[the noun]” in the editor, and the “natural language” quality of Inform makes it so easy to use a verb that makes sense in a vacuum.

Thanks so much! Hoping to duck my head back down and get to work figuring things out.

3 Likes

Yeah, @Draconis said something that stuck with me, which is that Inform’s natural language approach makes it really easy to read code and figure out what it does, but doesn’t necessarily make it easier to write code since it still has very specific, sometimes-finicky syntax requirements (wait 'til you start doing stuff with tables…) But there’s definitely a very powerful hivemind here to help out with the learning curve!

4 Likes