See how the text is coloured? I was wondering how I would create that.
Another thing is when you go to type something into a text box again is that the text box will clear. I was wondering how I could disable that so I can edit the box without it clearing.
Thanks
Edit: I found out how to disable the text clear on focus. Now, I was thinking of using string.match for colouring the text?
This would be very complicated to create on your own if your not a strong scripter since roblox does not currentlt support Rich text, but I believe they are planning to, here is a module that implements rich text in roblox: Rich Text Markup - Roblox. This system will be very difficult to create since the only game on roblox that has a feature like this is lua learning(Lua Learning - Roblox), which I believe the guy said took about 2 years to create.
Also, that module I linked currently has way more features that robloxâs beta, and this feature most likely wonât be out of beta for a few more months.
As @sjr04 said, a lexer will be needed, and this is a bit more complicated and will take a while. A lexer takes the whole string and gives you each needed piece of text that you need. Note that in this case, you only need to lex based on each color, so whatever class/tutorial you watch, I recommend you donât follow it exactly and make changes as needed.
So in your lexer, the following code should give you the following text:
local x = "hello there"
gives you:
local
x =
âhello thereâ
This is how I did it. After lexing, I would store the results in a table. This was a table of values which stored both the text and the word type (such as string, regular, etc). Then, I would go through the table, make a bunch of textlabels with their own colors and fonts, and put them all together.
There is a game âLua Learningâ made by boatbomber, this wonderful game has a code box, which supports the text that can be coloured, for instance the errors made in script. You can ask him an advice or a suggestion, he most likely tell you something about it, but he wonât give the whole code box script cause itâs a really hard work. Imagine doing a whole workable Lua code box inside the Roblox, that acts similar or almost matches the real code box in Roblox Studio.
I think the best way to contact with boatbomber is through twitter or discord or maybe through DevForum. @boatbomber
As someone said earlier, you need a lexer to break the text down into itâs Lua âcomponentsâ aka tokens.
Lucky for you, I open sourced one!
Using that, you can run the TextBox.Text through the lexer and create colored TextLabels based on the resulting token stream for your syntax highlighting!