Five Coding Questions in Inform 7

Hi there,

I’m newly registered to the board and all ready I have a problem. How presumputous, right?

Anyway, I need help figuring out how I can do six things for a puzzle line in my text adventure.

How can I have a scene trigger the moving of a character? When I put in this:

Move player to Dank Cellar.

I get:

Problem. You wrote 'Move player to Dank Cellar' : but I can't find a verb here that I know how to deal with, so I am ignoring this sentence altogether.

Dank cellar is all ready defined as a room and the manual says:

[code] 8.9. Moving the player

The player is a thing, too, and can also be moved, which has the effect of instantaneous transportation, without the need for a suitable map connection to the new location. For instance:

move the player to the Bodleian Library [/code]

So I don’t know what is wrong.

Second, how might I code being able to use a cup to capture a fly?

Third, how might I code a cat so that when the fly is released from the cup, it becomes distracted, and therefore takable by means of throwing a bag ontop of it? In essence: Putting the cat in the bag. But without allowing that to be used until he is in a state of distraction from the fly?

How might I code the ability to drop an object (the cat in the bag) down a toilet connected to a sewer? Would I code the toilet as a door? But I don’t want the player to be able to go down it.

How might I conceal a person in a room (a ghost) until as such time as a dead cat is used to see him and speak with him?

How might I have the ghost react differently based on what the player is wearing? I want him to give out different “quests” depending on whether I am wearing a different outfit. If no outfit is worn (the player’s normal clothes), I want the ghost to kill the player.

I’m quite new to authoring in Inform 7and if I am missing something in the manual just tell me the area in which it is located and I’ll pursue it there. Many thanks!

That’s what we’re here for! Well… one of the things.

It sounds like you’re trying to use “Move player to Dank Cellar” outside of a rule. All commands like “move player to Dank Cellar” have to be part of rules or phrases; otherwise Inform doesn’t know when to use them. This should work (changing “Your Scene” to the actual name of the scene):

When Your Scene begins: Move player to Dank Cellar.

Section 10.2 of the manual shows how to use “When Scene begins” and “When Scene ends” rules.

With the other questions, more details would help us help you. Maybe post sample transcripts, showing exactly what you would like to see happen. Some quick ideas:

If you don’t want the player to go down the toilet, then there’s no reason to make it a door. I would make it an ordinary thing and catch attempts to put things in it with a couple of Instead rules, like so:

[code]Instead of inserting something into the toilet:
say “You don’t want to lose that right now.”

Instead of inserting the bag into the toilet when the cat is in the bag:
say “You drop the bag into the toilet and flush. Bag and cat disappear into the depths of the sewers.”;
move the cat to Sewer;
remove the bag from play.[/code]

Is there any particular reason to have the ghost in the room but hidden? If not, I would start him off-stage (just put “The ghost is a man.” and don’t say where he is) and then use “move the ghost to Dank Cellar” (or whichever room) to make him “appear” when the player uses the dead cat.

Emerald:

Many, many thanks for your help! The scene seems to work now for the move. Is there anyway to include the first scene’s room description, though? I’d like for the player to be able to read what the description of the room is like, even if the intro won’t have one stay there very long (until the end of the intro’s text).

Sounds good. I’ll try to give you examples of each. I’ll post that in my next post in about 10 minutes. :slight_smile:

As to the toilet-code, thanks! I just inserted that. Running the game to see if it is okay. It is, though now I hvae to make the cat-in-the-bag.

I want the player to have to use the dead cat in order to see him. It’s an old exorcist’s ritual.

Thanks so much again. Expect the test code in a moment.

I have all ready coded a cup to be in a cupboard in a servant’s kitchen. Elsehwere, a fly will be found. Hmm, let’s say the fly is buzzing around…the Servant Privy (because it smells).

So I’d have something like:

[code]The fly is a person in the Servant Privy.

Instead of taking the fly, say “You can’t take the fly with [object]”.

Instead of taking the fly with the cup say, “You capture the fly in the cup”; move the fly to cup.
[/code]

Now when I put the above in, I get these errors:

[code]Problem. You wrote ‘Instead of taking the fly with the cup say, “You capture the fly in the cup”’ : but I can’t find a verb that I know how to deal with, so can’t do anything with this sentence. It looks as if it might be a rule definition, but if so then it is lacking the necessary colon (or comma). The punctuation style for rules is ‘Rule conditions: do this; do that; do some more.’ Perhaps you used a full stop instead of the colon?

Problem. You wrote ‘move the fly to cup’ : but I can’t find a verb here that I know how to deal with, so I am ignoring this sentence altogether.
[/code]

Onto the next question:

I want there to be a cat which is untakable unless it is distracted, therefore letting you sneak up and put it in a bag. The distraction would be the release of the fly, hwich would make the cat jump off the chair and go after it, therefore allowing you a chance to snag him in the bag. If you tried to take him, he would run off otherwise.

Here’s the code so far:

[code]The Lord’s Room is a room.

The Lord’s room is in the third floor.

There is a richly apholstered chair in the Lord’s Room. The richly apholstered chair is supporter.

A cat is a person in the Lord’s room.

The cat is on the richly apholstered chair.[/code]

ALl that code apparently works.

Basically, I have no idea what to do after that.

Basically, there are three outfits in the game you can find. The servant’s, the lord’s, and the lady’s. I want the ghost (who is the ghost of the Lord’s steward) to speak to you as if you are those people depending on what you are wearing. But if not, I want him to kill you as an intruder.

How might I write that at all? Also, would his appearance with the dead cat being used in his room be made via a scene? Or what? I am also having problems coding that.

To clarify, this is my puzzle line so far:

Get cup from cupboard in Servant Kitchen. (coded)

Use cup to capture fly in Servant Privy.

Get bag from somewhere (I haven’t decided yet).

Release the fly in the Lord’s Room to distract cat.

Use bag to take cat.

Drop the cat in the bag down the toilet. (coded)

Go to sewer and watch a scene where the cat gets out of the bag and kills a giant rat, which also kills the cat. (The giant rat kills the player otherwise). (Might need a bit of help with this but I haven’t tackled it yet).

Take the rat-gnawed key from rat’s nest. (coded)

Take the dead cat.

Use the rat-gnawed key to open the library door. (Coded)

Read "Dr. Satan Dracula’s “Summa Necromantica” to learn to use a dead cat to see ghosts. (Going to code it momentarily).

Use dead cat in Steward’s Room after you get the Servant (coded), Lord, or Lady outfit and wear it.

Speak to Steward as either of those people.

Hi!

You could create a new “catching it with action”:[code]Catching it with is an action applying to one thing and one carried thing.

Understand “catch [thing] with/using [something preferably held]” as catching it with.
Understand “take [thing] with/using [something preferably held]” as catching it with.
Understand “get [thing] with/using [something preferably held]” as catching it with.
Understand “use [something preferably held] to catch/take/get [thing]” as catching it with (with nouns reversed).

Check catching it with (this is the only catch animals rule):
unless the noun is an animal, try inserting the noun into the second noun instead.

Check catching it with (this is the can only catch with bag or cup rule):
unless the second noun is the cup or the second noun is the bag, say “You can’t catch [the noun] with [the second noun].” instead.

Check catching the cat with:
unless the cat is distracted, say “[The noun] keeps eluding you. If only you could distract it with something.” instead.

Carry out catching it with:
now the second noun contains the noun.

Report catching it with:
say “You capture [the noun] with [the second noun].”

Instead of catching the fly with the bag:
say “You wave the bag around, but it’s so bulky, you miss the fly every time.”[/code]Then you’ll probably want to create a “releasing” action. If not, you’ll need to adjust the taking rules to allow taking animals (normally blocked) for the situations when they’re in containers – otherwise, the player won’t be able to get them out. I’ll leave that to you. :slight_smile: Either way, you probably want to add something like:After dropping the cup: if the fly is in the cup: now the fly is in the location; say "As soon as you put the cup down, the fly escapes.".(Note that if you decide to allow the fly to be caught with other containers, you’ll need to adjust the above accordingly.) Then you could add a “distracted” property to the cat, but, if you only want it to be distracted with the fly, you could skip the property and just define a conditional “decide” phrase along with an every turn rule to describe the cat when distracted:[code]To decide if the cat is distracted:
if the fly is in the holder of the cat, decide yes;
otherwise decide no.

Every turn when the cat is in the location and the cat is distracted: say “The cat seems preoccupied with the fly.”.[/code]If you add all that to this sample scenario:[code]The cup is an open unopenable container. The bag is an open openable opaque container. The player carries the bag.

The lab is a room. The cup is in the lab. The fly is an animal in the lab.
The Back is north of the lab. The cat is an animal in the Back.

test me with “get fly / catch fly / take fly with cup / i / n / catch cat / bag / drop cup / use bag to get cat / i”.[/code]… you get this output:

I don’t now how that will all work in conjunction with the rest of your puzzles, but hopefully, it’s a start.

Edit: Note that the above quoted output doesn’t display the indents on the inventory lists properly, but in the game itself, things look the way they should.

In a word: you are the man. Thanks! I am going to try that out immediatly.

Both of you have been amazingly helpful so far. My project is really coming along thanks to your insight.

Another problem! Egads!

[code]A match is kind of thing. Understand the lit property as describing a match. Understand “lighted” or “flaming” or “burning” as lit. Understand “extinguished” as unlit.

Before printing the name of a lit match, say "flaming ".
Before printing the name of an an unlit match, say "extinguished ".

The match is a switched off device.

Carry out switching on match: now the location is lit.

Carry out switching off match: [if the room is dark] say “Darkness cloaks the room.”; [if the room is lit] say “The acrid smell of an extinguished match fills your nostrils.”

The player carries the match. “A match originally hidden in Arverus’ hair.”[/code]

This string of code works (the match lights up a dark room) but it has several bugs that are annoying and don’t come up as problems.

First, the match’s description doesn’t fit the description I gave of it “A match originally hidden in Arverus’ hair”.

Second, the match lists as “extinguished” regardless of whether it is on or not.

Third, I don’t seem to be able to say “light the match” (or strike the match) instead of “switch match on”.

Fourth, when I extinguish the match, it doesn’t follow my instructions of changing what it says depending on the condition of the room.

Also, how might one use the match to light something else? Considering a match has an extremely limited life, I want Arverus to be able to light something on fire to keep his light burning more. Eventually, he’ll have a lantern.

A few things here:

First, if you put a quoted description after an object’s definition, you are setting the initial appearance (the description printed the first time a player sees something in a room, which disappears after it is handled) not the description (the one printed after the command “examine”). (See ch 3.11.) Second, the description is applied to the subject of the previous sentence, which in this case is the player, not the match. This can be verified by typing “showme yourself” at the command prompt. Change the above to: The player carries the match. The description of the match is "A match originally hidden in Arverus['] hair." or, The match is carried by the player. The description is "A match originally hidden in Arverus['] hair." Also note, apostrophes in quoted material are expanded out to quotes. If you want an apostrophe, use [']."

“The match is carried by the player. The description is “A match originally hidden in Arverus[’] hair.””

Thank you! I’ll put that in right away. :slight_smile:

I forgot about the apostrophe thing. I read that command, but didn’t see a use for it yet.

Apparently, the cat is not distracting…

Okay, here, check this out:

[code]Chapter The Lord’s Room

The Lord’s Room is a room.

The Lord’s room is in the third floor.

There is a richly apholstered chair in the Lord’s Room. The richly apholstered chair is supporter.

A cat is an animal.

The cat is on the richly apholstered chair.

After dropping the cup:
if the fly is in the cup:
now the fly is in the location;
say “As soon as you put the cup down, the fly escapes.”.

To decide if the cat is distracted:
if the fly is in the holder of the cat, decide yes;
otherwise decide no.

Every turn when the cat is in the location and the cat is distracted: say “The cat seems preoccupied with the fly.”.[/code]

I think the problem is in here:

To decide if the cat is distracted: if the fly is in the holder of the cat, decide yes; otherwise decide no.

I am going to mess around with it.

Okay, I changed it to:

To decide if the cat is distracted: if the fly is in the location of the cat, decide yes; otherwise decide no.

But the problem is: The cat is on the apholstered chair. So being in the lord’s room doesn’t count as the location of the cat and I can’t drop the cup on the chair (which would be awkward anyway).

Hmmm. Perhaps if I make a command that moves the cat from the chair if the fly is in the lord’s room?

But how would I do that? My initial attempt doesn’t seem proper so far. Which is:

If the fly is in the lord's room move the cat to Lord's room.

Which doesn’t work, but doesn’t produce an error.

It didn’t occur to me that you’d have the cat on a chair. “Location” is the room, not the chair, but you have to account for the fact that if the fly is in a cup in that room, it’ll be in the same location. Try this (untested):To decide if the cat is distracted: if the holder of the fly is the location of the cat, decide yes; otherwise decide no.

What I mean is, can the player interact with the ghost in any way before using the cat? If not, I’d code it something like this:

[code]The ghost is a man.

Check using the cat in Place when the ghost is in Place:
say “You’ve already made the ghost visible.” instead.

Check using the cat when the cat is alive:
say “That won’t work. You need a dead cat.” instead.

Check using the cat when not in Place:
say “Nothing happens. Apparently there are no ghosts in this room.” instead.

Carry out using the cat:
move the ghost to Place.

Report using the cat:
say “The ghost appears!”[/code]
You’ll need to change “Place” to whichever room the ghost appears in, and “using the cat” to whichever action the player needs to take to use the cat. If it’s an action that already exists, this example might need tweaking.

It distracts the cat! BUT…

It doesn’t trigger saying the cat is distracted?

Which would be troublesome, as the player needs to know if he is distracted or not.

The new decide phrase seems to work fine, but you’ll need to adjust the every turn rule. The way it stands now, the cat is properly distracted, but the every turn rule doesn’t fire, so the player isn’t clued in. Change it to this:Every turn when the cat is visible and the cat is distracted: unless the cat is in the bag, say "The cat seems preoccupied with the fly.".

Perfect! The cat now appears as distracted obviously to the player, cluing him on what to do next.

Now, to figure out how to make the sewer work right. If I have problems with that, I’ll ask. But so far, you guys have been pretty damn helpful. :slight_smile:

Thanks Skinny Mike. You make me feel all tingly inside. :slight_smile:

Okay, now I am having a bit of trouble with the sewer.

What I want to have happen in the sewer is this:

If you enter into the sewer without a light, a giant rat kills you.

IF you enter into the sewer with a light, the giant rat kills you (but with a different message).

IF you enter into the sewer with a light and the cat has been flushed down the toilet in the hat (I changed it from a bag to a hat, because of ‘the cat in the hat’ LOL), the giant rat and cat kill eachother, allowing you to take a rat-gnawed key from the rat’s nest. Also, this allows you to pick up both a dead rat corpse and a dead cat corpse.

Haven’t heard that one in a while… :laughing:

Basically, I am thinking of making the command something like:

If the player is in the sewer: [if dark]"The gleaming eyes of a giant rat peer from the out the darkness. Scuttling your way with startling speed, it launches itself upon you and gnaws a gaping hole into your neck. In death, your body is eaten over the course of several weeks.""; end game [if lit]"A giant rat kills you"; end game [if lit and cat is in the sewer]"the giant rat and cat fight eachother to the death"; remove giant rat and cat from play; move rat corpse and cat corpse to sewer.

When I do this, hwoever, it doesn’t seem to work right…

It says:

Problem. You wrote 'If the player is in the sewer' : but the punctuation here ':' makes me think this should be a definition of a phrase and it doesn't begin as it should, with either 'To' (e.g. 'To flood the riverplain:'), 'Definition:', a name for a rule (e.g. 'This is the devilishly cunning rule:'), 'At' plus a time (e.g. 'At 11:12 PM:' or 'At the time when the clock chimes') or the name of a rulebook followed by some description of the current action (e.g. 'Instead of taking something:').

What am I doing wrong with these sorts of commands?

I tried more things. None have worked so far adn I am getting stumped.

If the player is in the sewer: if the sewer is dark: "The gleaming eyes of a giant rat peer from the out the darkness. Scuttling your way with startling speed, it launches itself upon you and gnaws a gaping hole into your neck. In death, your body is eaten over the course of several weeks.""; end game;[end if] otherwise if the sewer is lit: "A giant rat kills you"; end game;[end if] otherwise if the sewer is lit and the cat is in the sewer: "the giant rat and cat fight eachother to the death"; remove giant rat and the cat from play; move rat corpse and cat corpse to sewer.[end if][end if]

This gives me:

[code]Problem. The rule or phrase definition ‘If the player is in the sewer’ seems to use both ways of grouping phrases together into ‘if’, ‘repeat’ and ‘while’ blocks at once. Inform allows two alternative forms, but they cannot be mixed in the same definition.

One way is to end the ‘if’, ‘repeat’ or ‘while’ phrases with a ‘begin’, and then to match that with an ‘end if’ or similar. (‘Otherwise’ or ‘otherwise if’ clauses are phrases like any other, and end with semicolons in this case.) You use this begin/end form here, for instance - ‘end game’ .

The other way is to end with a colon ‘:’ and then indent the subsequent phrases underneath, using tabs. (Note that any ‘otherwise’ or ‘otherwise if’ clauses also have to end with colons in this case.) You use this indented form here - ‘if the sewer is dark’ .[/code]

I am thinking of just making a Rat Attack scene that triggers when you enter in the sewer. Would that work? Or what am I doing wrong?