Storing clean and efficient dialogue trees?

I’m trying to clean up my dialogue tree structure, and I feel the current setup I have is somewhat clunky and unorganised. This is a brief example of one of my characters dialogue. It’s ordered numerically, so dialogue goes down in order. Questions have 2 choices, each with an index of where they’d take you if you chose those. I also run functions like so, so if a choose is chosen that requires a function to be run then I can put stuff in it like so.

["Fisher"] = {
	Color = Color3.fromRGB(32, 128, 254),
	GetArg = function()
		return {FishSale}
	end,
	Messages = {
		[1] = {Msg = "Hello!<AnimateYield=0.25> What can I help you with?", Type = "Question", Choices = {{Text = "I want to sell my fish! 🐟", NextQuery = 2}, {Text = "I want to buy a new rod! 🎣", NextQuery = 5}}},
	
		-- Sell fish
		[2] = function() 
			FishSale = SellFish:InvokeServer()
			
			return 3
		end,
		[3] = {Msg = "You have sold all your fish for.<AnimateYield=0.25>.<AnimateYield=0.25>.<AnimateYield=0.25> <Color=75,211,60><Font=GothamBlack><Img=2283894564> %s", Type = "Normal"},
		[4] = {Msg = "Pleasure doing business with you! 😊", Type = "End"},
	
		-- Buy rods
		[5] = function() -- Buy rods
			print("Buy")
			
			return 6
		end,
		[6] = {Msg = "More fishing rods will be available in Beta!", Type = "End"}
	}
}

I just wanna get thoughts and opinions on how I could clean this up??

1 Like

For my dialogue system, I used string values and Color3 values stored in the NPC so I could easily change it.

Space your data across multiple lines for the sake of readability, e.g:

[1] = {
    Msg = "Hello!<AnimateYield=0.25> What can I help you with?",
    Type = "Question",
    Choices = {
        {Text = "I want to sell my fish! 🐟", NextQuery = 2},
        {Text = "I want to buy a new rod! 🎣", NextQuery = 5}
    }
},

Otherwise this to me looks like a good way of storing the data

1 Like

Is <AnimateYield=0.25> a RichText element? what does it do?

I believe it is for their text animations, waiting for a certain amount of time before continuing the animations, as implied by Yield being in the name.