Help with Dialog Script

Currently I’m trying to attempt to make a dialog system. I have a module script where it holds all the dialog and how many lines the dialog has. The only thing i can’t figure out is how to count how many lines the dialog has to say in order to stop

A little bit of more explanation:
image
This is my DialogLib where i store all the lines i currently have 6 lines for this NPC making 6 the maximum it can go
image
Inside the script i know running a for i, = 1, #b.WatchDogsPlayz do will warn all the lines in the module. I’m wondering how to set the max Lines to 6 and being able to tell the current line when the player progresses through the dialog (Example: lets say they finished the first line of dialog now they go to the second.) (Another Example: lets say they finished the dialog they reached line 6 once they reach line 6 close the dialog)

I would really appreciate it if I could get some help sorry if this is a little confusing to explain

3 Likes

maybe something like this?

local currentIndex = 1
local maxLines = 6

local b = {
	
	["WatchDogsPlayz"] = {
		[1] = "Line1",
		[2] = "Line2",
		[3] = "Line3",
		[4] = "Line4",
		[5] = "Line5",
		[6] = "Line6"
		
	}
}

for i = 1, maxLines do
	if b.WatchDogsPlayz[currentIndex] ~= nil then
		-- display the current line
		print("Line "..currentIndex..": "..b.WatchDogsPlayz[currentIndex])
		currentIndex += 1
	else
		-- end of dialog
		print("End of dialog")
		break
	end
end

return b

but i could be completely wrong

1 Like

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