0 votes

I would need an in-game code editor for having the player write python code. Is it possible to use godot editor components for this? If yes, how? Important features would be syntax highlighting and indentation. Suggestions are appreciated.

asked Jul 27, 2018 in Engine by meigel (26 points)

1 Answer

0 votes

Here is how the definition of the code editor component: https://github.com/godotengine/godot/blob/master/editor/code_editor.h
I found no evidence for scripting bindings to it though. So you could try to write an engine plugin to use the built-in editor. But I think it will probably be easier to implement the highlighting and indentation logic yourself. I'm afraid this is a task at which Godot does not especially shine.

I also thought about using one of the many JS highlighting frameworks and it really is a shame that we have no way to build some UI portions of our Godot games with web technologies, but it really seems undoable at the moment: https://www.reddit.com/r/godot/comments/73829a/how_might_one_render_web_pages_in_a_godot_game/

EDIT: If you need to include a python runtime anyway, maybe you can use http://pygments.org/ ?

answered Jul 27, 2018 by ConnyOnny (47 points)
edited Jul 27, 2018 by ConnyOnny

Thanks for the suggestions. Since I also need off-screen rendering, I might go with C++ QtSyntaxHighlighter and gdnative. Too complicated for my liking but unfortunately don't see any other option yet.

Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read How to use this Q&A? before posting your first questions.