How should I store Dialogue information?

:wave: Hello!

I’m currently working on a story game. The dialogue system is heavily inspired by that of Undertale and Deltarune.

I’ve been thinking of what the best way to achieve a dialogue system may be. Here’s what I have so far:

I’ve (mostly) gotten the visuals down. I’m simply wondering: what’s the best way to have all of the text and sounds stored?
I have the character sprites stored in a ModuleScript as I thought it might make the code much cleaner overall.

local Sprites = {
	["Jasmine"] = {
		["smile1"] = "rbxassetid://8371220589",
		["smile2"] = "rbxassetid://8371250696",
		["smile3"] = "rbxassetid://8371252080"}
	
}

return Sprites

Is this how I should also store the text, character names, voices, ordering, etc?
I’m also planning on doing proper translation, so it must be able to incorporate that.

ALSO: I’ve never done anything like this on Roblox so I might need help with figuring out how to get the script to display the text in the correct order.

Any help / feedback would be highly appreciated! :slightly_smiling_face:

Dictionaries! Unsure if those two games are linear stage-based storytelling, but you could store the dialogue scenes by location, linear order, people involved, etc. Since you want several factors, I’d nest all the information regarding the read text similar to this:

local dialogue = {
	firstDialogueScene = {
		personA = {
			EN = {
				["1"] = "first",
				["2"] = "second"
			},
			ES = {
				["1"] = "primera",
				["2"] = "segunda"
			}
		},
		personB = {
			EN = {
				["1"] = "and so on..."
			}
		}
	}
}

In this example, if I was starting a dialogue scene for the first time two people talk, I could code it by referencing:

print(dialogue.firstDialogueScene.personA.EN["1"])
--"first"

Anything that’s not scene-specific like names, voices, sprites can be in separate dictionaries so they’re easier to fetch. Note we have to use [“1”] instead of just 1 since dictionaries don’t except numbers as keys. The rest don’t need it but you could write it [“personA”] instead of personA, etc.

2 Likes