How to add python editor inside godot 3d game

Godot Version

godot 4.2

Question

i am currently creating a 3d game in godot 4.2. in which i wanted to add a python editor or text editor inside my game environment where when player clicks on a button the editor should popup in front of the player and the player can run there code in it. Can anyone help me how to add the python editor inside my game.

I have never used it, but there is a code edit node. This might be useful.

You would certainly have an easier time adding lua, there’s even a few plugins in the AssetLib.

  1. GitHub - WeaselGames/godot_luaAPI: Godot LuaAPI
  2. GitHub - Manonox/GDLuau: Luau C/C++ API bindings for the Godot Engine
  3. GitHub - gilzoide/lua-gdextension-distribution: Distribution repository for Lua GDExtension, submitted to the Asset Library

If you do not care about actually running the user’s scripts, or have already sorted out a python interpreter, the like Opalion said a CodeEdit node will get you 90% there. Play with the syntax highlighter, it’s a little rigid but GDScript is based on python so you should be able to get pretty close to python pretty highlights.

Code edit could help, but GDScript is explicitly not based on python, as said in the documentation.
https://docs.godotengine.org/en/stable/tutorials/scripting/gdscript/gdscript_basics.html

GDScript is entirely independent from Python and is not based on it.

Correct, based on is the wrong word to use. but it’s syntax is similar so the syntax highlighting process should be similar too. The very same doc page points this out

It uses an indentation-based syntax similar to languages like Python

1 Like

Hi, how did you manage to do this in the end? I have the same question atm