Create an easy dialogue system

Hello there!
I’m new here, I hope I won’t mess up anything with this post.
I have a pretty simple issue, but I suspect the solution won’t be so simple.

I want to create an interactive dialogue system, but I don’t want to have tons of branches on Twine for every single choice the player makes.
Here a pretty brilliant dialogue just to explain myself even more:
NPC “Hello, how are you?”
Player answer 1: “Fine”
Player answer 2: “Not so good”
NPC answer 1: “Good for you than!”
NPC answer 2: “I’m sad for you”

Obviously the NPC will reply accordingly to the player answer, different choices will appear to the player to go forward on the dialogue and so on. Classic

Now, I must say I have no knowledge in programming. So, is there some code I could just ctrl+c ctrl+v somewhere? :smiley:

Thank you very match for the help and patience!

2 Likes

Given your own dialogue written here, there is not an easy answer to copy and paste. However, making a simple dialogue system using Twine is not very complicated nor requires much programming language. All you need to know is the use of double square brackets around words and phrases to make links.

For your example, the following could be in a passage:

“Hello, how are you?”
[[“Fine”]]
[[“Not so good”]]

The NPC asked the question and the player could respond through clicking on one of the links created. That’s what the double square brackets around text does: it creates a link for a player. It also, in the Twine 2 editor, creates (if it did not exist) or connect (if it does) one passage to another.

You can think of passages as sections within a story. They might be scenes, places, or even just ways to break up the organization of the story. In this example, each dialogue choice would be its own passage. Putting double square brackets around the text would “connect” the passage to another with that exact name.

In another passage named ““Fine”” (note the double quotes!), you could then have different text for the player.

“Good for you than!”

Using different passages would be one way to cleanly branch around in Twine and write a dialogue system. However, as you mentioned not “want[ing] to have tons of branches on Twine for every choice the player makes,” there is another, slightly more complicated solution called conditional statements.

In Harlowe, the default story format, you can use the (link:) macro to create a link for a user. So, using the same text, the example might look like the following:

“Hello, how are you?”

(link: "Fine")[“Good for you than!”]
(link: "Not so good")[I’m sad for you]

For more advanced tracking, you might end of wanting to use variables and maybe conditional statements.

My recommendation would be to write it out using different passages because the Twine 2 editor makes it easy to see the connections and paths through the story. Then, if you want to use more code, you can always change it into something more advanced later.

1 Like

Just as a note, I removed the “dialog” tag and created “dialogue” and “conversation” tags to differentiate between conversational “dialogue” and Dialog, the new parser authoring system.

3 Likes

Ty so much man. I’m going to give a try to the more complex solutions, but if it doesn’t work, I’ll go directly with the simple “make a tons of passages” solution. If you say that I’m going to be fine anyway, so be it.

Thank you again :wink:

1 Like

It’s also useful to look at the code of twine games you admire. You can see their code by uploading their html file into your twine editor. I’ve learned a lot about Twine from doing this.

2 Likes

I don’t work in Twine, but ASM is very similar. What I tend to do is create a dialogue “hub” for each character, or several subject-node hub passages in a long conversation. As @videlais suggested, there will be tons of passages but that’s inevitable and the currency when writing complex choice-narrative.

I usually have a passage that’s the conversation or node entry:

:farmer-conv:
<<if $$title eq 'farmer-conv'>>
You greet the produce farmer. "Sup?" he says. 
<<endif>>
<<if $$title neq 'apples'>>
[[Tell me about apples|apples]]
<<endif>>
<<if $$title neq 'peaches'>>
[[Tell me about peaches|peaches]]
<<endif>>
<<if $title neq 'beets'>>
[[Tell me about beets.|beets]]
<<endif>>
[[Gotta go.|backtothefarm]]

Then for each specific conversation passage, there’s the response text with follow up questions, and I re-display the original conversation-hub passage to show the menu and if-else to hide that specific question on its own page so the player isn’t asking the same thing twice in a row.

:apples:
My apples are the best in the land! I especially like Honeycrisp varieties!
[[Tell me about Honeycrisp.|honeycrisp]]
<<display 'farmer-conv'>>

What this will do is display the apples response, and the new “honeycrisp” link at the top, and then redisplay “farmer-conv” where it will hide the initial greeting and the “apples” link (since we’re already there) but show all the other questions with their respective links.

(In ASM $$title means “The main passage on the screen, but not any subsequent ones pulled in for display”. It may be something different in Twine/Harlowe/Sugarcube.)

1 Like

The way I’d tackle it is:

  1. Open your favorite editor (not word-processor - you want plain text that you can cut ‘n’ paste later.)

  2. Write a bunch of dialogue, simply brainstorming and letting the characters “talk amongst themselves.” Don’t worry, no matter how much dialog you write, you’ll always find you have to write more of it. Games always need a lot more dialogue than you think, to deal with different contingencies.

  3. Think about the different dialog branches you’ve written in terms of information content, e.g. “has key”, “knows poison apple”, “knows village name” etc. These are the purposes, or targets of the conversation.

(BTW it’s always best to state terms in positive terms: e.g. “has spoken to old Wibbley”. It makes the statements clearer to read. If you make the statements negative: e.g. “hasn’t answered sphinx” then you get involved in double negatives, and it’s easier to get in a muddle.)

  1. Now you can make each “information target” a particular Twine passage (you can either have the passage flip a flag, or simply check to see if the player has seen that passage.) Link the passages together with straightforward bare-bones requests like “ask about poison.” Now the Twine passages show the structure of your conversation.

I’d make a backup at this point. :slight_smile:

  1. Now you fancy up your links by cutting and pasting in the dialog you wrote in that text editor, thinking about things like characterization and continuity (and obfuscating things to some extent – you don’t want to have a bunch of lukewarm options and one BLINDINGLY OBVIOUS one, even if the player is in a “chute” and will eventually learn all the essential clues no matter what choices are picked.)

It will get messy at this point, as you provide alternative choices, chop up sentences to allow for phraseology, or add variation if the player is going to see passages more than once etc. I find that this sort of logic-chopping messes with my (undoubtedly meager) ability to write real-sounding dialog: I can’t do both at the same time, which is why I suggested doing all the “writing” in a separate app.

There’s no way around it though: dialogue takes a ton of work, and it’s messy.

Best of luck!

2 Likes