2 Noob Questions

Hi all. I’m learning how to use Inform right now while building my first tiny, modest game. Two things I don’t understand:

  1. How can I make an NPC stop a player from going into the next room unless he is given an object? For example, you have to give your ticket to the man at the ticket booth before you are allowed north to the Theater.

  2. How can you combine/repair objects with other objects to get them to work? For example, putting a battery in a flashlight before the flashlight will light up?

Can someone just point me towards the code behind these concepts, or maybe a tutorial?

Thanks in advance.

First one, I’m assuming a very simple world model:

Instead of going north in the presence of the usher when the usher does not carry the ticket: Say "'Your ticket sir?' the usher asks." The block giving rule is not listed in any rulebook.

Second one should be in the recipe book, example 139, under chapter 10.7.

Note that the second one is not a “noob” question in any sense of the word; it’s rather involved, actually!

Thanks for the quick response! In regards to this…

Instead of going north in the presence of the usher when the usher does not carry the ticket: Say "'Your ticket sir?' the usher asks." The block giving rule is not listed in any rulebook.

what would the next few lines be? How do I make him accept the ticket in return for passage?

So nothing, unless you want to add flavor text. You might want to have a look at Section 7.4 of the Recipe Book.

Wow! Thanks for the quick responses. I used the wrong example: instead of a flashlight with a battery, what I mean is, combining two items to create a new item. Example:

Use stick with rubber band.

You now have a slingshot.

Instead of tying the rubber band to the stick: Remove the noun from play; Remove the second noun from play; Now the player carries the slingshot; Say "You now have a slingshot." Instead of tying the stick to the rubber band: Try tying the rubber band to the stick. Instead of inserting the rubber band into the stick: Try tying the rubber band to the stick. Instead of inserting the stick into the rubber band: Try tying the rubber band to the stick. Understand "combine/use [something] with [something]" as tying it to.

OK. That helped. Last question: I want to create an item called Lit Pipe. To do this, the player must get the Pipe, Tobacco and Matches. He must put the tobacco in the pipe and light it with the match. Then, the item will become “Lit Pipe.” How do I do all of that?

Here’s a reasonably crude implementation:

[code]Smoking Room is a room.

The pipe is a container in Smoking Room. The tobacco is in Smoking Room. The match is in Smoking Room.
The lit pipe is a thing.

Instead of inserting something into the pipe when the noun is not the tobacco, say “This pipe only holds tobacco.”

Lighting it with is an action applying to two things. Understand “burn [something] with [something]” as lighting it with. [“light” is already understood as a synonym for “burn”.]
Instead of lighting something with something, say “You can’t light things with [the second noun].”
Instead of lighting something with the match, try burning the noun.

Instead of burning when the player does not hold the match: say “You need the match to light things.”
Instead of burning the tobacco when the player holds the match and the tobacco is not in the pipe: say “[The noun] has to be in a pipe to be lit.”
Instead of burning the pipe when the player holds the match and the tobacco is not in the pipe: say “[The noun] doesn’t have any tobacco in it.”
Instead of burning when (the noun is the pipe or the noun is the tobacco) and the player holds the match and the tobacco is in the pipe:
say “You light the tobacco-filled pipe.”;
now the lit pipe is in the holder of the pipe;
remove the tobacco from play;
remove the pipe from play;
remove the match from play.
Instead of burning: say “That’s not flammable.” [/code]

This relies pretty heavily on the rules applying in the right order – the “Instead of burning” rule doesn’t apply in any of the more specific cases. If you compile this, it’s worth going to the “actions” tab of the index and looking at the magnifying glasses next to “burning” and “lighting it with” to see what order the rules are in. There’s more on specificity in section 18.18 of the documentation (and if I were a better coder I could probably have made my code better by exploiting specificity more elegantly).

Thanks sooooo much! I hope I’m not asking too many questions of you all, but this has been a big help. My game is going great so far! Inform is fun as hell. :smiley: