I don’t think this is the best way to make it. And I’ve seen some pretty good dialog systems so there’s gotta be a better (and more readable) way to do this
The way I would layout my dialogue module would be:
-- DIALOGUE
local DIALOGUE = {
{
text = "* [wave]<b>Hello there!</b> [/wave]",
speaker = "Chara",
icon = "rbxassetid://0"
},
{
text = "* [shake]You're finally <i>awake.</i>[/shake]",
speaker = "Sans",
icon = "rbxassetid://0",
onStart = function()
-- once this specific dialogue shows up
-- blah blah blah
end
},
{
text = "* [rainbow]Lets not[/rainbow]",
speaker = "Chara",
icon = "rbxassetid://0",
onEnd = function()
-- once this specific dialogue ends
-- blah blah blah
end
},
{
text = "* [wave]<i>You are suddenly filled with determination.</i>[/wave]",
speaker = "Guide",
icon = nil
},
{
text = "* [shake]HAHAHAHAHA[/shake]",
speaker = "System",
icon = nil
},
{
-- ends the dialogue
-- You could either have something like this or have the dialogue close once you reach the end of the list.
ending = true
}
}
-- OPTIONS
local OPTIONS = {
onEnd = function()
-- once all dialogue is finished
--- hehe
end,
onStart = function()
-- once the dialogue first appears
-- whatever...
end
}
return {
dialogue = DIALOGUE,
options = OPTIONS
}