Prevent dialogue from pausing when there's more than one special character

I have made a typewriter styled dialogue system, and I have added a feature where the dialogue stops momentarily when it comes across a dot, comma, explanation mark, you get the idea.

However, I want to add a new part in this feature where if there is more than one of a character that pauses the dialogue all back to back, then it only pauses on the last character. How can I do this?

This is a video of the current system.

I have tried no solutions as there is not a single one that I have thought of yet, I’d appreciate any help.
This is my code.

function text(text, ignore, name)
	local displayText = text

	-- Replace line break tags so grapheme loop will not miss those characters
	displayText = displayText:gsub("<br%s*/>", "\n")
	displayText:gsub("<[^<>]->", "")

	-- Set translated/modified text on parent
	main.frame.Text.Text = displayText
	main.frame.tName.Text = name

	local index = 0
	for first, last in utf8.graphemes(displayText) do
		index = index + 1

		main.frame.Text.MaxVisibleGraphemes = index
		local character = string.sub(displayText, index, index)
		if configs.skip == true then
			game:GetService("RunService").RenderStepped:Wait()
			ignore = true
		else
			wait(configs.dialoguespeed)
		end
		if table.find(textpauseicons, character) and not ignore then wait(0.5) end
	end
	if not configs.skip then
		if not configs.auto then
			repeat game:GetService("RunService").RenderStepped:Wait() until KeyVerify()
		else
			wait(1)
		end
	else
		game:GetService("RunService").RenderStepped:Wait()
	end
end

Check if the next character is also in the textpauseicons and not ignore, something like
"if table.find(textpauseicons, character) and not ignore and not (table.find(textpauseicons,string.sub(displayText, index+1, index+1) and not ignore) then wait(0.5)

this would be problematic if its the last character, but that shouldn’t be too hard to figure out (just make the loop not care about the last character and add in an extra if statement for it without the modification

Note you might need some bug checking since idrk anything about UI stuff, so although the logic works, the code might not

The logic did indeed check out and the code did not but I managed to write some working code for this logic.
Thank you for the help : D

1 Like

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