Devlog #4 - Advanced Dialogue System


The dialogue system from Procedural Dungeons works, but it has a lot of issues.

Main Problems with the Old System:

  • The dialogue box is static and doesn’t move to uncover things on the screen.
  • Must be typed in the editor
  • No spell checks
  • The dialogue code is difficult to remember and type (not easily human readable)
  • Features are too difficult to add
  • Some symbols can’t be represented in dialogue { [ < > ] }

 

Solution:

I want to create a new dialogue system that fixes all of these issues for Squirrel Launcher. I decided to completely scrap Procedural Dungeon’s dialogue system and make a new one. This new system will allow dialogue boxes to appear anywhere on the screen. Tutorials will use this system to point at specific objects and give instructions. I also intend to never have to redesign a dialogue system again by making it easy to add features without tearing the code apart and putting it back together.

 

Technical:

Dialogue needs a better way of being input. I’ve decided that I’m going to basically write a programming language to support this. Here is a bit of the syntax and features.

 

Dialogue is typed out just how you’d expect it to be.

"Inside quotes is one line of dialogue." "The next line can be accessed by pressing button to advance."

Escape characters can be used.

"Quotes can be represented like this: \"" "Backslash can be represented like this: \\"

Commands are represented by square brackets. These can do all sorts of things. They are read and parsed whenever they are found just like in Procedural Dungeons.

They can set focus objects which are which character is speaking or where the tutorial window should be pointing.

[focus: Bob] "I want that cake!" 

The first part of the command is the command name and the second part is the parameters.

[question: yes, no] "Do you want pasta?"
[branch: yes] "Nice, here you go."
[branch: no] "Unfortunate." [end branch]

Jump commands can be used to jump to a line number or a tag.

[tag: start]
[jump line: 4]
"Wrong answer."
[question: yes, no] "Does pineapple belong on pizza?"
[branch: yes] [jump line: 3]
[branch: no] "Correct." [end branch]
[jump tag: start]

Text can be assigned based on the reference dictionary in the dialogue system with the reference command.

[reference: forward button] "Press ~forward button~ to move forward."
[reference: key] "~value~" <- represents the key and value in a dictionary respectively

Multiple symbols can be replaced with the reference command

[reference: jump, shoot] "Use ~jump~ to jump and ~shoot~ to shoot.

Rich text is represented entirely within Text Mesh Pro’s solution.

[rich] "<color="green">This is green text. </color>This is normal text."

With the rich command, while inside of <> symbols, quotes and escape sequences are ignored. The text inside is also read instantly as opposed to other text which is read gradually. The rich command only applies to the next dialogue line. It has to be called for every line that needs it.

Text can be applied to the start of every following line of dialogue with the header command.

[header: <color="green">] "This is green text." "This is still green text."

Quotes inside of commands don’t count as lines of dialogue

Headers can be removed by replacing it with a new header or by using the end header command.

[end header] "This is normal text."

 

The pass command passes control to another dialogue file and returns control return once it is done.

"Controls:" [pass: controls/overworld controls] "End of controls."

Dialogue can be displayed in different spots using the box command.

[box: top] "This moves the dialogue box at the top of the screen."
[box: bottom] "This moves the box back to the bottom of the screen (the default)."

The same command exists for both the left and right of the screen as well as a mini box.

Focus objects are a separate component attached to game objects that contain information about what they are looking at. They can contain information about where mini dialogue boxes are represented. They also can display their name in the dialogue box to represent who is talking.

[focus: squirrel1] "Squeak!"

Controlling dialogue system

Here are the functions that control the dialogue system:

ReadRaw (string value)

This function takes in a string as if it was a text file and follows all of the same rules.

Read (string textFilePath)

This function looks in the dialogue folder for a text file and then calls the print function with its contents.

SetReference (Dictionary references)

Replaces the dialogue system wide reference dictionary that is used with the reference command.

AdjustBox (string[] settings)

Adjust dialogue box settings such as its dimensions


Demo

Here is a demo of all of the features:

This is the dialogue script that this video uses. It is split into three files so occasionally it will switch between them.


Get Squirrel Launcher

Leave a comment

Log in with itch.io to leave a comment.