Conversation Flow - Inform 7

Hello,

I am looking for source code for a normal 3-person conversation including the player. Nothing fancy just talking and maybe asking questions with answers.

I would appreciate it if you could guide me or just paste some sample code.

Thanks

Is there a particular authoring system you’re interested in? If so, you might want to edit your thread title to include that, or move it to the appropriate Authoring sub-category, so folks can be get you stuff you’d find useful!

Can you suggest the section I need to move it to?

That depends - are you looking for Inform 7, or 6, or TADS, or Twine, or some other specific system? If so, that’s the one I’d move it to. If you’re familiar with multiple subsystems and would be interested in anything, I’d just say that (and maybe move into the overall Authoring category, which tends to be where folks offer sample code).

Sorry man, I forgot to mention it is for Inform 7. Can I leave it there or do I need to move it? I will add Inform 7 to the title.

You might have slightly better luck moving it, though I think most folks just look for the latest posts across all categories, so probably no big deal now that you’ve got I7 in the title!

I think an initial question is how you’re handling dialogue generally - traditional ask/tell, a menu based extension, etc.? And then how you want the player to experience the flow.

I’ve done a few three way conversations in Inform, though they’re mostly in my first game where all the dialogue was implemented as individual “instead of” rules so sharing the actual code would be an act of cruelty! But sometimes I’d just have a third party add an aside after asking the other NPC about something (if your NPCs can wander, you’d need to test whether the other one is around, of course); there were also times when I just wrote the dialogue out for all parties regardless of who the player addressed, so the rule triggered when asking npc1 or npc2 about topic X. And then there were extended sequences that I basically just wrote up as cutscenes.

Thanks Mike.

No, I don’t want anyone to give their games codes as that will be wrong from me to just copy and past then I will not learn how to do it myself.

So, what I am asking is if you or someone else can just give me an example in code how it should look like, what I need in the code and where I must put it.

I have tried a few examples but still not clearly grasp just a normal conversation/dialogue between two or three people including the player.

Let me tell you what I am interested in doing, say there is a meeting and the player will attend the meeting. He will listen with other NPC’s and then there will be questions or introductions from the NPC running the meeting. The player or NPCs should be able to answer back and so it will continue.

I am just so sure how to start something like this and how basic code for this will look like, meaning what I need to get started and go on from there.

Hope this makes more sense. Sorry, I am totally new to this, I only started last week.

There are various ways to implement this. If you want to have complete control over the flow of conversation, it would be easiest to use a multiple-choice extension like “Hybrid Choices” by AW Freyr: extensions/Hybrid Choices.i7x at 9.3 · i7/extensions · GitHub

If you instead use the traditional method of conversation, i.e. ASK NPC ABOUT … or TELL NPC ABOUT …, then it’s more difficult to establish a consistent flow, because the players can in principle ask about anything at any time.

You can take a look at Eric Eve’s conversation extensions like Conversation Nodes, which come with code examples. They are really good, but require a bit of learning and overhead to get going.

I’d also recommend checking out the Recipe Book, section 7.6 (Getting Started with Conversation) and following.

Having said all that, here’s a very bare-bones example without using any extensions:

The Conference Room is a room.

Adam is a man in the Conference Room.
Berenice is a woman in the Conference Room.

Meeting Stage 1 is a scene.
Meeting Stage 1 begins when play begins.
Meeting Stage 1 ends when the time since Meeting Stage 1 began is 4 minutes.

Every turn during Meeting Stage 1:
	say "Adam says: [one of]'Our plan starts with the first step.'[or]'We will follow that with the second step.'[or]'Finally, we will implement the third step.'[or]'That's it. Any questions or ideas?'[stopping]".

Check asking Adam about something during Meeting Stage 1:
	say "Adam is busy explaining the plan. He will answer questions later." instead.

Check asking Berenice about something during Meeting Stage 1:
	say "It would be rude to talk to Berenice while Adam is speaking." instead.

After asking Adam about "the/-- plan":
	say "You ask about the details of the plan. Berenice nods and asks: 'Yes, aren't there some prerequisites before the first step?'".
	
After asking Berenice about "prerequisites":
	say "You ask Berenice what kind of prerequisites she means. Berenice says: 'It's what I call step 0.' Adam nods, 'Good point.'".

Test me with "z/ask adam about first step/ask berenice about plan/z/ask adam about plan/ask berenice about prerequisites".

This uses a scene to constrain the player a little bit while the first NPC explains something over several turns, before conversation becomes possible. You could chain several scenes together in order to simulate various stages of the meeting, where different questions are allowed.

As I said, this is just a very basic example, showing one possibility to get you started. In a game, you’d also want to handle “TELL NPC ABOUT …”, not just “ASK NPC about …”. And you might want to enforce that the players can only ask about something after they heard about it, and so on.

2 Likes

Thanks, I will try this, looks like it might work, I will see.

Sloley I am getting there with Inform 7.
I have the following lines from my code:

Instead of talking to Westley, start a conversation with Westley-hello.

Westley-hello is a chat node. "We will start with Joe,".

Rule for finding responses to Westley-hello:
	link to Westley-chat-1; link to Westley-chat-2.

Lower down in my code I want to have another conversation with Westley like:

Instead of talking to Westley, start a conversation with Westley-cic.  [This should be a new conversation]

Westley-cic is a chat node. "'Okay, we want to turn it over to Sherry, the current incident commander now to give us an update on current operational conditions. Sherry.'".

The problem I cannot seem to resolve is when I first talk to Westley the Westley-hello chat note is the response, but when I talk to Westley again with the Westley-cic chat node i still get the Westley-hello response and not the Westley-cic response.

How can I restrict Wesley-hello chat node to only one response and never again, same with the Westley-cic chat node?

I haven’t used the chat extension which you got from the other thread, so I can’t comment on the specifics of that.

But you could, for example, introduce and set flags (booleans / truth states), so something like this should work:

Greeted-Westley is a truth state that varies.

Instead of talking to Westley:
	if greeted-westley is false:
		start a conversation with Westley-hello;
		now greeted-westley is true;
	otherwise:
        start a conversation with Westley-cic;

Thanks, will try it out - looks like it might work if I can incorporate it with the chat nodes.

I have added the code but get the following error:

true-false error2

First image with the semicolon as you gave it to me

true-false error

Second image with the full stop as suggested by the first image.

Not sure how to change this to get it to work.

I have tried the full stop as well, same thing.

What extension do I need for this to work?

What does your code look like? You need to have the exact formatting as shown in my example above. (Well, there are also other ways to go about this, but the formatting is important: put “:” after rule preambles like “Instead of …” and after "if … ", and indent with a tab, and end statements like “now …” with “;”.)

This is part of the code with your suggested code inserted.

Maybe I did it wrong somehow, not sure.

The Meeting Room is a room. 
Westley is a man in the Meeting Room. "[line break]Hello, I'm West Magara from Virginia DEQ. I'm going to let the other agency administrators introduce themselves.".

Joe is a man in the Meeting Room. It is undescribed.

Lucy is a woman in the Meeting Room. It is undescribed.

Carol is a woman in the Meeting Room. It is undescribed.

Greeted-Westley is a truth state that varies.

Instead of talking to Westley:
	if greeted-westley is false: 
		start a conversation with Westley-hello.
		now greeted-westley is true;
	otherwise
		start a conversation with westley-cic.

Westley-hello is a chat node. "We will start with Joe,".

Rule for finding responses to Westley-hello:
	link to Westley-chat-1; link to Westley-chat-2.

You have introduced a full stop here:

start a conversation with Westley-hello.
now greeted-westley is true;

but it should be a semicolon (as it is in my example above), because we want to tell Inform that several statements belong to that block. So:

start a conversation with Westley-hello;
now greeted-westley is true;

Additionally, you omitted the colon “:” after otherwise:

otherwise
		start a conversation with westley-cic.

should be

otherwise:
		start a conversation with westley-cic.

Thanks, much appreciated.

I will fix it and try again.

Silly mistakes can keep you searching for the wrong answers.

I only added your parts of the code in between my code but did not realise I had full stops and you example had semicolons.

Well, I guess this is how I learn, from mistakes and people like you who can guide me in the right direction.

Thanks again.

1 Like

Tried it and it works perfectly, thanks