So, to make Lua Syntax is kinda easy.
You need to use gsub and string patterns to make syntax.
Keywords:
local str = "script."
local Ingore =
{
["="] = true,
["."] = true,
[","] = true,
["("] = true,
[")"] = true,
["["] = true,
["]"] = true,
["{"] = true,
["}"] = true,
[":"] = true,
["*"] = true,
["/"] = true,
["+"] = true,
["-"] = true,
["%"] = true,
[";"] = true,
["~"] = true
}
local highlight = ""
str = string.gsub(str,'\46',function(c)
if Ingore[c] then
return " "
else
return c
end
end)
highlight = string.gsub(str,'%\83+',function(c)
if c == "script" then
return "script"
else
return (' '):rep(#c)
end
end)
print(highlight)
String:
local str = '"fisi"\n"s"'
local boolean = false
local highlight = ""
str:gsub('\46',function(c)
if c == '"' and boolean == false then
boolean = true
elseif boolean == true and c == '"' then
boolean = false
end
if boolean == true and c ~= '"' then
highlight = highlight .. c
end
if boolean == false and c == '"' then
elseif c == "\n" and boolean == false then
highlight = highlight .. "\n"
elseif c == "\t" and boolean == false then
highlight = highlight .. "\t"
elseif boolean == false then
highlight = highlight .. " "
end
end)
5 comments
Syntax highlighting inside of Roblox TextLables or on a website?
TextLabels
Or text boxes, i know i can use multiple labels but it would cause lag
Check this out: https://devforum.roblox.com/t/sectionsstring-change-color-font-size-etc-of-parts-of-textlabels/352406
alright