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.

in Engine by (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/ ?

by (49 points)
edited by

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 Frequently asked questions and How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to [email protected] with your username.