Discuss Scratch
- Discussion Forums
- » Help with Scripts
- » Dialogue Engine
- Janwyn
-
35 posts
Dialogue Engine
Dear Scratchers,
I want to build a dialogue engine that can:
The engine would help me write dialogue for my coming sequel to my recently-released game Journey to The Moon, whose linear, hand-coded dialogue was so painful to create that I want to write the next game's dialogue with an engine that runs from a loop.
A traditional list-and-loop dialogue solution works only for two characters: I want to write scenes with at least three speakers. Therefore, I need a non-traditional list-and-loop solution, but I do not know how to make my characters wait their turn to speak–or even how to control the length of time a line is displayed. Can anyone help me?
Sincerely,
Janwyn
I want to build a dialogue engine that can:
- Read lines from a list
Display them on cue
Wait for a time depending on the line's length
Pause between lines
Handle interruptions
The engine would help me write dialogue for my coming sequel to my recently-released game Journey to The Moon, whose linear, hand-coded dialogue was so painful to create that I want to write the next game's dialogue with an engine that runs from a loop.
A traditional list-and-loop dialogue solution works only for two characters: I want to write scenes with at least three speakers. Therefore, I need a non-traditional list-and-loop solution, but I do not know how to make my characters wait their turn to speak–or even how to control the length of time a line is displayed. Can anyone help me?
Sincerely,
Janwyn
- bjskistad
-
1000+ posts
Dialogue Engine
Do you want pen or clones? There are multiple text engines out there… It just depends what you want…
- Janwyn
-
35 posts
Dialogue Engine
@bjskistad
@SkyShine
I should have been clearer. I have several sprites, each representing one character, each of whom has lines to read from a script like actors in a play. I want an engine that will control who says what, when, and for how long, preferably with each character reading from the same script.
@SkyShine
I should have been clearer. I have several sprites, each representing one character, each of whom has lines to read from a script like actors in a play. I want an engine that will control who says what, when, and for how long, preferably with each character reading from the same script.
- BKFighter
-
1000+ posts
Dialogue Engine
Sprite 1 @bjskistad
@SkyShine
I should have been clearer. I have several sprites, each representing one character, each of whom has lines to read from a script like actors in a play. I want an engine that will control who says what, when, and for how long, preferably with each character reading from the same script.
Sprite 2
Sprite 1
Sprite 3
Sprite 1
Sprite 4
Sprite 3
and so on…
- bjskistad
-
1000+ posts
Dialogue Engine
This is great for a conversation, but not reading text…Sprite 1 @bjskistad
@SkyShine
I should have been clearer. I have several sprites, each representing one character, each of whom has lines to read from a script like actors in a play. I want an engine that will control who says what, when, and for how long, preferably with each character reading from the same script.Sprite 2Sprite 1Sprite 3Sprite 1Sprite 4Sprite 3and so on…
- Janwyn
-
35 posts
Dialogue Engine
@BKFighter
I used something like that before, waiting until a variable called Line equalled a value hand-coded for each line, and broadcasting a message called Conversation after the talking. But I write so much dialogue that this process is bothersome: I want to write my lines into a list variable and have my characters read them. The progam that would control their line-reading I call a dialogue engine.
I used something like that before, waiting until a variable called Line equalled a value hand-coded for each line, and broadcasting a message called Conversation after the talking. But I write so much dialogue that this process is bothersome: I want to write my lines into a list variable and have my characters read them. The progam that would control their line-reading I call a dialogue engine.
- asivi
-
1000+ posts
Dialogue Engine
Have yo got a txt file with a script like this?
-character 1
How are you?
-character 2
I'm fine, thanks.
-character 1
Your kitten, is fine too?
-character 3
Miauuu!
If it's so then you can import it to a list. I think that the code for management is not hard.
-character 1
How are you?
-character 2
I'm fine, thanks.
-character 1
Your kitten, is fine too?
-character 3
Miauuu!
If it's so then you can import it to a list. I think that the code for management is not hard.
- asivi
-
1000+ posts
Dialogue Engine
Have yo got a txt file with a script like this?
-character 1
How are you?
-character 2
I'm fine, thanks.
-character 1
Your kitten, is fine too?
-character 3
Miauuu!
If it's so then you can import it to a list. I think that the code for management is not hard.
-character 1
How are you?
-character 2
I'm fine, thanks.
-character 1
Your kitten, is fine too?
-character 3
Miauuu!
If it's so then you can import it to a list. I think that the code for management is not hard.
- Janwyn
-
35 posts
Dialogue Engine
Have yo got a txt file with a script like this?
-character 1
How are you?
-character 2
I'm fine, thanks.
-character 1
Your kitten, is fine too?
-character 3
Miauuu!
If it's so then you can import it to a list. I think that the code for management is not hard.
Thanks for the list-importing idea. I never knew you could do that. But what I still don't know how to do is how to have each sprite read that script and decide, based on it, when to speak. Do you know how to do that?
- asivi
-
1000+ posts
Dialogue Engine
If you refer to the amount of time to display each sentence it can be associated to the length of the text.
If the character has to do some action before speaking it can be performed by using variables or broadcasting messages.
If the character has to do some action before speaking it can be performed by using variables or broadcasting messages.
Last edited by asivi (Dec. 16, 2015 22:57:47)
- Janwyn
-
35 posts
Dialogue Engine
If you refer to the amount of time to display each sentence it can be associated to the length of the text.
If the character has to do some action before speaking it can be performed by using variables or broadcasting messages.
Thanks! I was thinking of controlling which character speaks when by prefacing their lines with their names and having each character speak only when the second letter of the line is his name's second letter (the first letter of two characters' names is the same) but I cannot omit the name from what the character says. I could maintain another list of names, having my characters check it and read from a name-less list of lines, but maintaining two lists would be quite unpleasant. Alternatively, I could interpolate the characters' names with the lines, but interpolations would only confuse me when I would write them. Any ideas?
EDIT: I could just create a new block called “Speak,” which would take an input number and read the associated line from the script, but a loop seems more-elegant.
Last edited by Janwyn (Dec. 16, 2015 23:40:04)
- footsocktoe
-
1000+ posts
Dialogue Engine
For a dialogue, all you need to know is who is talking, what they are going to say, and for how long they will say it.
The way lists work is that if you import a text file you create yourself, then each line (between two carriage returns) will be one item in the list.
The idea above about controlling the time by counting how many letters in the line is good and it means you can use an ordinary playscript textfile.
If your textfile contains blank lines you could write in code to ignore them.
Your idea about using the first two letters in an item to determine the name is good. But if the playscript text file has the name followed by a colon, then it will be easy to detect the colon and use the rest of the line for the dialogue, while counting what comes before the colon as the name of the speaker. (Possible glitch: There is a colon in the line being spoken. Rare, but it could happen.)
I like this idea for a project so much that I will be working on my own version. I'll bookmark this topic to see how you are progressing and let you know what I come up with.
The way lists work is that if you import a text file you create yourself, then each line (between two carriage returns) will be one item in the list.
The idea above about controlling the time by counting how many letters in the line is good and it means you can use an ordinary playscript textfile.
If your textfile contains blank lines you could write in code to ignore them.
Your idea about using the first two letters in an item to determine the name is good. But if the playscript text file has the name followed by a colon, then it will be easy to detect the colon and use the rest of the line for the dialogue, while counting what comes before the colon as the name of the speaker. (Possible glitch: There is a colon in the line being spoken. Rare, but it could happen.)
I like this idea for a project so much that I will be working on my own version. I'll bookmark this topic to see how you are progressing and let you know what I come up with.
- Janwyn
-
35 posts
Dialogue Engine
For a dialogue, all you need to know is who is talking, what they are going to say, and for how long they will say it.
With the tools available in Scratch, knowing these things is no mean feat.
The way lists work is that if you import a text file you create yourself, then each line (between two carriage returns) will be one item in the list.
The idea above about controlling the time by counting how many letters in the line is good and it means you can use an ordinary playscript textfile.
If your textfile contains blank lines you could write in code to ignore them.
I might just do that one day, but for now, I'll use the list editor.
Your idea about using the first two letters in an item to determine the name is good. But if the playscript text file has the name followed by a colon, then it will be easy to detect the colon and use the rest of the line for the dialogue, while counting what comes before the colon as the name of the speaker. (Possible glitch: There is a colon in the line being spoken. Rare, but it could happen.)
I like this idea for a project so much that I will be working on my own version. I'll bookmark this topic to see how you are progressing and let you know what I come up with.
The second letter–not the first two.

- footsocktoe
-
1000+ posts
Dialogue Engine
Good idea with the colon: every character's dialogue would have it in another place. But how would I remove the name and colon from the dialogue?
That would be simple. When the list is being read by the code, it will be creating a variable called LINE for each item and a variable called NAME for each item.
Since each item will be read starting at the first letter, the letters go into NAME (using the JOIN block) until the colon is reached (using an IF THEN block to find the colon). Then the colon doesn't go into any variable, but now as the code continues to read through the letters of the item, it puts the rest of them in LINE.
When the end of the item is reached, then LINE is put in a SAY block which is given to the character NAME.
(An alternative would be to present the line as a subtitle at the bottom of the screen with the name still attached to it.)
Meanwhile, the list reader has incremented to the next item and when the time is up (time determined by the length of LINE just displayed) the process repeats again.
Last edited by footsocktoe (Dec. 17, 2015 10:31:51)
- Janwyn
-
35 posts
Dialogue Engine
Thanks for the help, guys, and especially to MLTI-Conference, who made and posted this dialogue engine, a modified version whereof I will use in From Terra to Luna, my upcoming sequel to Journey to the Moon: https://scratch.mit.edu/projects/1075372/. I may also release the engine as a standalone project afterward because it supports acting via endcoded costume changes.
- emmet2000
-
18 posts
Dialogue Engine
I tried making one:
https://scratch.mit.edu/projects/103169238/
https://scratch.mit.edu/projects/103169238/
- Dylan_TheBest7
-
3 posts
Dialogue Engine
Hey! if anyone wants to know, here is how to make the “when this sprite clicked” block more complicated.
Thanks for reading!
- Dylan_TheBest7
-
3 posts
Dialogue Engine
a
sorry
sorry
Last edited by Dylan_TheBest7 (Sept. 8, 2023 23:34:24)
- Dylan_TheBest7
-
3 posts
Dialogue Engine
you can do
Sprite 1
Sprite 2
Sprite 1
Sprite 2
Last edited by Dylan_TheBest7 (Sept. 8, 2023 23:36:29)
- Discussion Forums
- » Help with Scripts
-
» Dialogue Engine