So I’m trying to create a little script editor but it doesn’t function like I want it to, I want it to keep the delemitters. Like this:
local string_ = "local Instance.new"
I made it so that the string splits on dot spaces commas etc…
Then I change to colors so that it’s like the script editor, after that the comma’s and dots are gone, can someone help me keep them?
This my function right now:
local wordColors = {
["local"] = {248, 109, 124},
["Instance"] = {132, 214, 247},["new"] = {132, 214, 247},["Vector3"] = {132, 214, 247},["UDmi2"] = {132, 214, 247},
["true"] = {255, 198, 0},["false"] = {255, 198, 0},
["0"] = {255, 198, 0},["1"] = {255, 198, 0},["2"] = {255, 198, 0},["3"] = {255, 198, 0},["4"] = {255, 198, 0},["5"] = {255, 198, 0},["6"] = {255, 198, 0},["7"] = {255, 198, 0},["8"] = {255, 198, 0},["9"] = {255, 198, 0},
}
local delims = {",", " ", ".",":"}
function multiSplit(String, delims)
local Table = {}
local p = "[^"..table.concat(delims).."]+"
for Word in String:gmatch(p) do
table.insert(Table, Word)
end
return Table
end
local function update()
currentText = promptTextBox.Text
local words = multiSplit(promptTextBox.Text, delims)
for i, word in next, words, nil do
if not wordColors[word] then continue end
local color = wordColors[word]
words[i] = string.format(
'<font color = "rgb(%d, %d, %d)">'..word..'</font>',
color[1],
color[2],
color[3]
)
end
promptTextBox.Text = table.concat(words, " ")
end