Community > Your scripts

Dialog Box script with Name Displayed

(1/2) > >>

I wanted to have the name of the person speaking displayed in at the top of the dialog box, so I modified the dialog_box.lua script by Christopho (I used the one from Children of Solarus since it looked to be the most up-to-date version).

The new syntax for the dialog text uses a line beginning with '##' to specify the displayed name. Without any lines beginning with '##', no name will be displayed and the behavior of the text box is the same as it was before.

The name will also be applied to subsequent panes within the same dialog until it is changed by specifying a new name. Beginning a line '###' turns the displayed name off again.

Beginning a line with '##>' shifts the name over to the top-right side of the dialog box. This is useful if you want the player's name to appear right-justified while the names of all other NPCs are left-justified.

Finally, beginning the displayed name text with '&' signifies that the given name is actually a savegame variable key and its current value will be used for the name text that gets displayed (e.g. '##>&player_name').

Lines beginning with '##' must be the first line of a set of lines for a given pane.

Sample dialog text:

--- Code: (lua) ---dialog{ text = [[
First Pane: Beginning the line with two
'#' characters causes the name Hector to
appear at the top of the dialog.
Second Pane: The name Hector continues
to be shown in subsequent panes as well.

Third Pane: Note the empty line above is
used to complete the previous pane for
it to have 3 lines of text (even empty).
Fourth Pane: Putting 3 '#' characters at
the start of a pane causes it to display
no name at the top of the dialog.
Fifth Pane: The > immediately after the
'#' characters causes the name to be
shifted over to the right.
Sixth Pane: This can be useful to show
the player's name. In this case, the
text shown is literally 'Player'.
Seventh Pane: Here the '&' character is
used to instead display the value of a
savegame_variable named 'player_name'.

--- End code ---

The modified script (GNU GPL v3, originally by Christopho) is attached along with a modified version of dialog_box.png (CC BY-SA 4.0, originally by Metallizer & Olivier Cléro)

This is very cool! Thanks for sharing. I might use this.

I fixed a bug where I had forgotten to clear the displayed name when the dialog is closed, so the old name would appear when starting a new dialog if no name was specified.

The updated script can be found in the original post.

I implemented this in VOADI - thank you!

I was concerned that it would be hard to merge with my existing script (I modified it from Christopho's original) but Meld made it easy to see the diff side-by-side and click the changes over.

I'm excited to see the impact this feature will have on the quality of my dialogue.

Cool! Have any pics?

What other mods did you make to your dialog box script?


[0] Message Index

[#] Next page

Go to full version