In-game script editor. Where do I start?

In Lua Learning, there’s a script editor in-game where you can write code just like an actual script editor. I tried to make one myself but I just found it too confusing.

What I want to achieve is that richtext that is made when you put code in.

From this:

To this:

Any help is appreciated!

For the syntax highlighting part, the first thing you’ll need is a lexer (lexical analyzer), which will be able to tokenize the source (script) and yield back keywords such as things like: number, comment, operator, built-in function etc. that can then be used to change the color of the desired words (parts of the provided source). Each tokens’ source text color can be changed using a separate textlabel (for different colors), or when we get rich text support, which seems to be soon, you could use that and it should make things even easier.

There are a many ways you can write your own lexer, but maybe doing some research on how lexers work and can be built in general might help?

This also might be a good starting point (or all that you need)


To render the text, @boatbomber has said before that he had to parse the text into a million TextLabels and ImageLabels for his editor. RichText support has been discussed so we may be able to skip the million text labels and just be able to parse context in the future and apply different effects to them.

So first step is Lexer, second step is a bunch of text label generation. Or waiting


Took a while for me to understand the module but I got it now haha. Thanks!

I documented the process of creating my Lua Learning IDE, so I’m sure you’ll find some helpful lessons here:

I also open sourced the lexer from it, so that’s a huge piece of the puzzle handed to you: