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
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.
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