I’m looking through the chat system, and I see in ClientChatModules’ script ChatSettings, there’s a variable defined as “disallowedwhitespace.” Can anyone tell me what this does?
This avoids creating whitespaces while typing those following in the input, ignoring the string manipulation logic through that. That’s my current guess.
What do you mean by “whitespaces”? Like excessive spaces in the chat bubble or classic chat?
Indeed. \n
is the newline or EOL which makes it jump down to the next line rather than filling the chat.
Good to know. Thank you!
chatlimitchatlimitchatlimit
DisallowedWhiteSpace doesn’t prevent the characters from being entered into the input, what it does is filter out those whitespace types from a sent message. The processor for it is MessageCompleted, meaning when the message is sent.
Over ignoring them (which it can’t, otherwise it’d show up), it removes the character completely via gmatch. This is because the string is literally processed, rather than by how it appears.
This is the snippit of code for which DisallowedWhiteSpace is used in (ChatScript.ChatMain):
if not CommandProcessor:ProcessCompletedChatMessage(message, ChatWindow) then
if ChatSettings.DisallowedWhiteSpace then
for i = 1, #ChatSettings.DisallowedWhiteSpace do
if ChatSettings.DisallowedWhiteSpace[i] == "\t" then
message = string.gsub(message, ChatSettings.DisallowedWhiteSpace[i], " ")
else
message = string.gsub(message, ChatSettings.DisallowedWhiteSpace[i], "")
end
end
end
message = string.gsub(message, "\n", "")
message = string.gsub(message, "[ ]+", " ")
local targetChannel = ChatWindow:GetTargetMessageChannel()
if targetChannel then
MessageSender:SendMessage(message, targetChannel)
else
MessageSender:SendMessage(message, nil)
end
end