Is there a way I can code in my own game?

To put it simply, you can just use loadstring() on the content of a TextBox. Or, you can opt for the tricky route and included syntax highlighting and the prevention of malicious code.

For the complex method, you will need:

  • A lexical analyser (lexer). There is an open source one available here.
  • A highlighting module, this simply creates Text Labels behind the text to make it nice and colourful.
  • A protection system for executing code. There is an open source one available here.

Great, but what is a lexer?
A lexer is a module that identifies what stuff is. Basically, it returns tokens that have information on the text you ran on it. For example, / would return operator.

1 Like