Fixing Up a Dialog System

I have this simple dialog system setup and I’d like to get feedback so I know if I should continue with it

local Dialog = {
   [1] = {

      ["Speaker"] = {
         "Example Text",
         "Example Text 2"
      },

      ["Player"] = {
         "Example Text"
      },

      ["FunctionToCall"] = giveReward,

      ["Options"] = {
         [1] = {
            ["Speaker"] = {
               "Example Text",
               "Example Text 2"
            },
            ["FunctionToCall"] = example
         },
         [2] = {
            ["Speaker"] = {
               "Example Text",
               "Example Text 2"
            },
            ["FunctionToCall"] = example2
         }
      }

   }

}

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

4 Likes

These module names are very vague.
Could you explain what these do?

1 Like

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
}

>:3

1 Like

There’s only one module, sorry if that was a bit unclear

This looks about right, but are these separate from each other? What if you wanted to “chain” dialogue (like a conversation)?

Maybe I’ve got it confused, but you can let me know.

I’ll award you as the solution since I don’t think there’ll be anymore feedback

1 Like

I don’t quite understand what you mean.

Like multiple conversations in one module orr???

1 Like

Yeah sorry for the late response, but yeah I mean multiple back and forth conversations or conversations involving multiple people

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.