Help On Dialogue System

As the title suggests, I want to create one module that handles any dialogue added to my game, though I have no idea how I could make this. I haven’t tried attempting to do this either because I have no clue on how I can attempt this.

My plan to make this is to have two main modules that act as the backend of the system. The Dialogue Manager will act as the backend verifying and supplementing the dictions to see if everything is good, and the Dialogue Handler that’ll act as the frontend of the system. Basically, the Handler will add any of the effects and will mainly be the GUI editing.

Of course, at the time of editing the code is very bare-bone and has barely any functioning features

--Manager
local module = {}

function module._init(Dialogue_Data)
	local success, data = pcall(function()
		assert(typeof(Dialogue_Data) == "table", "Dialogue Initializer expected Table.")
		return Dialogue_Data
	end)

	if not success then
		warn(data) -- Output the error message generated by assert
		return nil
	else
		return data -- Return the Dialogue_Data table if successful
	end
end


return module
--handler
local UIS = game:GetService("UserInputService")

local TypeWriteModule = require(script:WaitForChild("TypeWriter"))
local ManagerModule = require(script:WaitForChild("Manager"))

local module = {}
module.__index = module

function module.CreateDialogue()
	
end

return module
3 Likes

I don’t really know what to say, because you’re asking to make a giant dialogue system but you say that you haven’t got a clue as to how to go about it. You also haven’t given us any details. I can give you a plan and tell you how you could approach it, however I can’t make nothing from nothing.

My bad, I’ve thought of an idea. I’ll edit my post

1 Like

Could you explain what the dialogue system actually is? Will it replace the chat or instead be dialogue boxes the player uses to interact with npcs and such?

Also, in your init function, you don’t need to use pcall when running assert, nor print the error message generated from it. Assert will do that automatically, meaning you can simply just have

function module._init(Dialogue_Data: table): table?

  assert(typeof(Dialogue_Data) == "table", "Dialogue Initializer expected Table.")
  return Dialogue_Data

end
2 Likes

Interaction with NPC’s or interactions that will cause inner-dialogue.

Just wanted to check before digging into your code, but have you seen this community resource yet? Advanced Dialogue System + Node Editor

1 Like

Yeah, I actually have the plugin for it, I just wanted to create my own system just to learn and to make it easier for adding my own stuff into it.

1 Like

Yeah, I’m just going to stick with this since it’s more reliable than a module like this

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