MrDialogue defines conversations as graphs composed of line, choice, branch, action, and end nodes. Dialogue state, conditions, and actions run on the server. The package includes a client interface and supports custom adapters.
Installation¶
Add MrDialogue to wally.toml:
Then run wally install and map the package into ReplicatedStorage.
Example¶
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local MrDialogue = require(ReplicatedStorage.Packages.MrDialogue)
local directions = MrDialogue.new({
format = 1,
id = "directions",
entry = "greeting",
nodes = {
greeting = {
type = "line",
text = "Do you need directions?",
next = "answer",
},
answer = {
type = "choice",
options = {
{ id = "yes", text = "Yes.", next = "directions" },
{ id = "no", text = "No, thanks.", next = "done" },
},
},
directions = {
type = "line",
text = "Follow the road north.",
next = "done",
},
done = {
type = "end",
result = "finished",
},
},
})
Start the definition for a player from the server:
local session, startError = directions:Start(player)
if not session then
warn(`Could not start dialogue: {startError}`)
end