Skip to content

Python & Console Tools

Most of what you’ll want to do has a dedicated tool. For the rest, Direktor offers two escape hatches.

run_python executes arbitrary Python in the editor’s process using Unreal’s unreal module. It’s the universal fallback for multi-step logic, loops, or an API that no first-class tool covers yet.

Because it can do anything you could do in a Python script — including modifying or deleting assets — it is disabled by default. Enable it under:

Project Settings → Plugins → Direktor → Tool Permissions → Enable Python Tools

While the setting is off, run_python still appears in your client’s tool list, but its description starts with “DISABLED in this project” and calls are refused. Once enabled, the assistant can run code. When the code matches something a first-class tool does better, the result includes an agent_hint nudging the assistant toward that tool. Changing the setting tells connected clients to refresh their tool list.

From Python, import direktor lets a script call other Direktor tools with call, try_call and atomic(). A run_python or flow call nested inside one is refused with NOT_NESTABLE. During Play In Editor, a Python write that depends on the selection is refused with PIE_RUNNING before it changes anything.

run_console_command passes a command straight to the Unreal console: the same commands you’d type into the editor’s console window (stat fps, r.ScreenPercentage, show flags, and so on).

This tool is enabled by default. Unreal blocks genuinely destructive console commands in the editor context, so it’s a low-risk way to toggle overlays, stat readouts, and rendering switches. You can turn it off under Project Settings → Plugins → Direktor → Tool Permissions → Enable Console Tools.

The target parameter picks where a command runs:

  • auto (the default): the Play In Editor session while one is running, otherwise the editor. During a play session this includes editor commands, so pass editor for a command meant for the editor level.
  • editor: the editor world.
  • pie: the play session. Refused when none is running.

The first line of the reply names the target and world the command ran in. During a play session, MAP, BUILDLIGHTING, BUILDPATHS and BUILDMATERIALTEXTURESTREAMINGDATA are refused; stop the session first.

To close the editor, use quit_editor. Plain quit and exit are rejected in the editor and only end a play session.

While Python tools are off, console commands that would reach Python, such as py, ServerExec or SendToConsole, are refused on every target.

  • A dedicated tool exists → use it. Better ergonomics and clearer feedback.
  • An Unreal API with no dedicated tool → the capability catalog (search → describe → invoke).
  • Multi-step logic, loops, or something genuinely custom → run_python.
  • A console command → run_console_command.