N00b having problems.

This is the first story I ever wrote.
I want a character to react to being asked something by the player by taking a key she stores in her jacket, unlocking the door to her house, and entering it and shutting the door. Well, that’s easier said than done. So far I’ve tried to get her to unlock the door, so the player can enter the room, just to test it. Because that isn’t even working so far, I’m not even bothering with I’ll copypaste what’s relevant.

There’s two rooms:

The heavy grey painted door is a door. The heavy grey painted door is east of the hallway of my apartment and west of the house of the neighbor. The description of the door is "This is the grey painted door of my neighbor." The Heavy grey painted door is lockable and locked. The key of the grey painted door unlocks the heavy grey painted door.

Then I create the woman and her clothes and her key:

In the hallway of my apartment is a woman called the old lady that lives next to you. The dark green skirt is worn by the old lady that lives next to you. The grey shirt is worn by the old lady that lives next to you. The old fashioned grey jacket is worn by the old lady that lives next to you. A container called the left pocket is part of the old fashioned grey jacket. The left pocket is openable. The left pocket is closed. The key of the grey painted door is inside the left pocket. The description of the old lady that lives next to you is "'This is the old lady who lives next to me. She has gray hair and wrinkled skin. I could ask her for help. I probably should.' You can ask her about a subject by typing: ask about 'subject'." 

Then I have a bunch of code about what should happen when the player asks this old lady about the salon:

After asking the old lady that lives next to you about "salon", 
	say "You ask her about the hair salon. blablablablabla".
After asking the old lady that lives next to you about "salon", 
	try The old lady that lives next to you trying opening The left pocket.
After asking the old lady that lives next to you about "salon", 
	try The old lady that lives next to you trying taking The key of the grey painted door.
After asking the old lady that lives next to you about "salon", 
	try The old lady that lives next to you trying unlocking The grey painted door with The key of the grey painted door.

Well, guess what, when i type “ask old lady about salon” I do get “You ask her about the hair salon. blablablablabla”. However, the door is not unlocked, because I can’t open it. She doesn’t even open her left pocket, which I tested by opening her pocket after talking to her. What am I doing wrong? She does say something. Could anyone explain what I’m doing wrong?

What you’ve done is set up four separate rules, only one of which will trigger. Inform looks for an After rule, finds the first most specific one the applies, and (since it’s an after rule) ends the action after that rule fires. Since the first rule takes care of all the actions, the other three rules are never used at all.

You want a single rule that does all this. That’s done on the following form:

After asking the old lady that lives next to you about "salon", say "You ask her about the hair salon. blablablablabla"; try The old lady that lives next to you trying opening The left pocket; try The old lady that lives next to you trying taking The key of the grey painted door; try The old lady that lives next to you trying unlocking The grey painted door with The key of the grey painted door.

Juhana’s post not too long ago illustrates how rules interact, which could be useful to know.

Thanks for the quick answer.
I’ve replaced this:

After asking the old lady that lives next to you about "salon", say "You ask her about the hair salon. 'Good morning Mrs. Parker.' You say. 'I want to visit a hair salon called 'So Fabulous, but I don't know the adress.' 'So Fabulous? Oh I often go there. The adress is Pearl Street 15, it's easy to find, but it's quite a ride from here. But what's a young lad like you got to do there?' The question makes you a little nervous, and you notice that your neighbor can tell that you're getting nervous. 'I'm picking up a girl who works in the salon to go on a date.' 'Oh a date, how lovely, which of the girls are you dating?' Your neighbor asks delighted.'Sally' You answer, picking the first female name that entered your head. 'Sally eh?' The woman answers. 'Isn't she a little old for you? Besides, does she really still work at the salon? I thought she quit ages ago.' You're getting increasingly nervous before you manage to utter 'It's nice talking to you Mrs. Parker, but I really have to go now.' That's not a lie. You should really get going now, and take a cab. 'Ok Steven, now you two have fun, and don't do anything stupid dear!' The woman says to you as she walks to the door of her apartment. You can't help but feel that she treats you as her teenage son. You don't like it.". After asking the old lady that lives next to you about "salon", try The old lady that lives next to you opening The left pocket. After asking the old lady that lives next to you about "salon", try The old lady that lives next to you tr taking The key of the grey painted door. After asking the old lady that lives next to you about "salon", try The old lady that lives next to you trying unlocking The grey painted door with The key of the grey painted door.
With this:

After asking the old lady that lives next to you about "salon", say "blabla"; try The old lady that lives next to you trying opening The left pocket; try The old lady that lives next to you trying taking The key of the grey painted door; try The old lady that lives next to you trying unlocking The grey painted door with The key of the grey painted door.
But now inform gives the following errors:

I’ve seen these errors before, and thus I made the four separate rules, because that made the errors disappear, but Inform only carries out the first. However, I don’t understand this error or how to fix it. Inform says it can’t find a verb. The verbs are there though. Opening the pocket, taking the key, and unlocking the door. What do I do to get rid of the errors?

No problem, I’m happy to help. If I was of any help, heh.

I think you’re taking too large steps between checking. Consider this as me speaking with my programmer hat on, but generally, you want to keep things simple. As soon as you make a change, test it to see that it doesn’t break the program. Don’t add things and actions you don’t need. Always test, test, test. Do you need the pocket for the key, is it relevant for the world model? Or can you simply describe the key as being held by the lady? And so on.

Naming a person “The old lady that lives next to you” in the code strikes me as a bit hard to follow. It could be a source of bugs, particularly since I’d wager “you” already represents something. This can be worked around by referencing the printed name of the person. The same danger arises when you have names like “the key of the painted green door.” It’s hard to tell, without looking at the rest of the code, what Inform will make of it, but I’d not be surprised if it’s checking for “the painted green door” and trying some kind of relation.

I think you’ll gain a lot by simplifying everything to the basics of what you want to see happening in the game, instead of trying to script the details of every motion. For instance, a made-up example from a recent movie:

   now Anakin readies his lightsaber;
   say "'You will [italic type]try[roman type]...'";
   now Anakin ignites his lightsaber;
   now Anakin bends his knees;
   now Anakin straightens his knees;
   carry out the Force Jump activity with Anakin;
   carry out the Landing activity with Anakin and Obi-Wan;
   carry out the Lightsaber Cut activity with Anakin and Obi-Wan;
   [...repeat until driven into exhausted coma.]

I’d argue that this is a case of overthinking it. You don’t need to model everything, especially not cause-and-effect relationships the player won’t be able to notice. When you write the code itself, and its objects, you’re really describing properties (i.e. how things act, not what they’re actually supposed to be seen as in the game). A lot of how these things are perceived is just going to be inferred. Creating objects and assigning them special characteristics means you choose to make them significant in some way. Otherwise, you may want to show it happening in the description text itself.

The problem with this code is that you’ve put a comma after the title of the rule (“After asking the old lady that lives next to you about “salon””) instead of a colon. As you discovered, you can only use a comma there when the rule has a single instruction; any more, and you need to use a colon instead. You’ll probably find it’s easiest to use a colon for all rules, in case you want to add an instruction later.

I haven’t tested it, but this code should compile:

After asking the old lady that lives next to you about "salon": say "blabla"; try The old lady that lives next to you trying opening The left pocket; try The old lady that lives next to you trying taking The key of the grey painted door; try The old lady that lives next to you trying unlocking The grey painted door with The key of the grey painted door.

Eleas gives good advice, though. Unless there’s a possible situation where the old lady won’t be able to unlock the door (she lost the key, or the lock is jammed, or whatever), you can probably just unlock the door directly, like so:

After asking the old lady that lives next to you about "salon": say "blabla"; now the grey painted door is unlocked.

Gah, I didn’t even catch that! Knew I should have tried compiling any advice I gave. Well spotted, sir/ma’am.

Thanks guys. I’ve replaced the comma with a colon. I’ve also followed Eleas advice of simplifying the names because they could confuse inform. “The old lady who lives next to me” is now simply called “the old lady” throughout the code. the grey door is now simply called “the grey door” and it’s unlocked by “the grey key”.

This is what I tried first:

[code]In the hallway of my apartment is a woman called the old lady. The dark green skirt is worn by the old lady that lives next to you. The grey shirt is worn by the old lady that lives next to you. The old fashioned grey jacket is worn by the old lady that lives next to you. A container called the left pocket is part of the old fashioned grey jacket. The left pocket is openable. The left pocket is closed. The grey key is inside the left pocket. The description of the old lady is “‘This is the old lady who lives next to me. She has gray hair and wrinkled skin. I could ask her for help. I probably should.’ You can ask her about a subject by typing: ask about ‘subject’.”

After asking the old lady about “salon”:
say “blabla”;
try The old lady trying opening the left pocket;
try The old lady trying taking the grey key;
try The old lady trying unlocking The grey door with the grey key.
[/code]
This won’t work, the old lady refuses to do anything. However, I’ve also tried this:

After asking the old lady about "salon": say "blabla"; now the grey door is unlocked.
This does work, because when I use this, I can open the door as the player, so it does get unlocked.
I then turned it into:

After asking old lady about "salon": say "blabla"; now the grey door is unlocked; try old lady going east.
This worked:

[code]
hallway of my apartment
You can see a grey door, a green door and the old lady here.

ask old lady about salon
blabla
The old lady goes east.[/code]
This is the first time I’ve managed to make a character successfully try something, so I was happy I finally got it to work.
She leaves the door open (I tested it by trying to open the door myself as the player):

>open grey door That's already open.
I made the full code of the segment:

After asking old lady about "salon": say "blabla"; now the grey door is unlocked; try old lady going east; now the grey door is closed; now the grey door is locked.
And tested it:

[code]>ask old lady about salon
blabla
The old lady goes east.

open grey door
It seems to be locked.[/code]
Thus the old lady stops bothering the poor player, and the player can’t chase after her into her room in the apartment either. I’ve finally gotten rid of her. :laughing: Thanks guys, you helped me solve this problem that I couldn’t get figured out.

If you were really set on the old lady being named ‘the old lady that lives next to you’ during gameplay, you could always add the following stand-alone line into your program:

The printed name of the old lady is "the old lady that lives next to you".

This way you could leave the code as is, while still using the phrasing you had originally intended during in-game events. :slight_smile:

In general, it’s not necessary to have an NPC actually carry out a string of actions like this. You can simply change the state of the game yourself, by executive order as it were, and then TELL the player that the NPC did a bunch of stuff.

Something like this (untested):

Instead of asking the old lady about "salon": say "The old lady unlocks the door, goes inside, and slams the door."; now the old lady is in the entry hall.

–JA