How to make door openable after talking to two characters?

I am starting off with the player in a car with two NPCs. I want the car door to be unopenable until the player has TALKED TO both characters.

I have attempted using IF statements but keep getting errors, maybe because there are two conditions?

Having trouble finding this in the Recipe Book. I am very new to Inform 7, so I really appreciate any input

When you’re asking these sorts of questions, it’s helpful if you post the relevant parts of what code you currently have at the moment (working or otherwise) – use the </> button so that the forum doesn’t mess up the formatting.

This can both serve to help illustrate your problem as well as make it more likely that people will frame their answers in terms of the particular objects you’re using in your code, making it more immediately applicable.

For this specific question, there are a number of ways that things can be done.

The simplest is to initially declare the car door as locked, and then in the rule where you’re responding to the talk to action, say something like now the car door is unlocked. (A locked door with no matching key can only be unlocked by you, not the player.)

For sweeping changes to the world based on triggering actions, you could also look into using something like scenes.

Either way, you’re going to have to have some way to keep track of which people have been spoken to and which haven’t. There are many different ways to do this as well – and which makes more sense may depend whether these are throwaway characters only used in this scene or if there’ll be extended interactions with them throughout the course of the story.

Writing with Inform and the Recipe Book do attempt to make a gentle introduction to Inform but you do have to get a fair way into them (and play with several of the examples) before they’re much help writing an original work. It does get easier once you’re used to the conventions, of course.

If you’re coming from a programming background (or if you’re familiar with one of the more code-like IF languages), then this might be a useful read – and it can be treated as a “cheat sheet” for most of the supported syntax in one place. (Some of its advice is a little outdated, as it was written for a much older version of the compiler and library – but it still serves as a good introduction if you have that background.)

2 Likes

Hiya, there are about a million billion ways of doing this, but this’ll prob. get you going.

"doortest" by Ade

Understand "talk to [someone]" as chatting.
 
chatting is an action applying to one thing.

A person can be chatted or unchatted. A person is usually unchatted.

Check chatting:
	if the noun is not a person:
		say "You can't talk to that!" instead;
	if the noun is the player:
		say "Stop talking to yourself!" instead.

Carry out chatting:
	say "You chat for a bit.";
	now the noun is chatted;
	if the front door is locked and Bob is chatted and Sue is chatted:
		say "The front door unlocks with a click!";
		now the front door is unlocked.
	
		
Orchard is a room.

House is a room.

Bob is a person in Orchard.

Sue is a person in Orchard.

The front door is a locked door. It is south of Orchard and north of House.
1 Like

I was able to make a scene change after talking with both NPCs in the car. Now I’m having another issue.

I have moved the player and the NPCs to a new area “Front yard” which is outside the car, but when I “talk to” the NPCs I don’t get the new text I’ve written, but the text from when we were in the car:

Understand the commands "ask" and "tell" and "say" and "answer" as something new.

Understand "ask [text]" or "tell [text]" or "answer [text]" or "say [text]" as a mistake ("[talk to instead]").
Instead of asking someone to try doing something:
	say "[talk to instead][paragraph break]".

Instead of answering someone that something:
	say "[talk to instead][paragraph break]".

To say talk to instead:
	say "(To communicate in [story title], TALK TO a character.) "

Understand "talk to [someone]" as chatting.

chatting is an action applying to one thing.

A person can be chatted or unchatted. A person is usually unchatted.

Check chatting:
	if the noun is not a person:
		say "You can't talk to that!" instead;
	if the noun is the player:
		say "Stop talking to yourself!" instead.

Carry out chatting:
	now the noun is chatted;

Understand "talk to [someone]" as talking to. Understand "talk to [something]" as talking to. Talking to is an action applying to one visible thing.


Car Ride is a scene.  Car Ride begins when play begins. 

Back Seat is a room.

Kat is a person in Back Seat.  

After chatting Kat, say  "'What's up, Kat?'..."


Rob is a person in Back Seat. 

After chatting Rob, say "'How much ..."

Car Ride ends when Rob is chatted and Kat is chatted. 

Front yard is a room. 

The House is a scene. The House begins when Car Ride ends. 

When The House begins:
	move Rob to Front yard;
	move Kat to Front yard;
	now player is in Front yard.
	
	
	
after chatting Rob, say "'I bet ..."

Oof, looks like your formatting is a bit messed up – you can use the </> button in the toolbar above, or put three `s around your code, to get it to appear in a more readable way.

Looks like the issue is you have two After Chatting Rob rules, but you’re not telling Inform which one to use when, so it’s just picking one. The conceptual issue might be that you’re thinking that once you say a scene has changed, anything below there will be in the new scene? But scenes can be repeated so this isn’t how Inform works. What you need to do is rewrite the rules to reference the specific scenes:

After chatting Rob while Car Ride is happening, say "How much..."

After chatting Rob while The House is happening, say "I bet..."
2 Likes