godotengine / godot-vscode-plugin

Godot development tools for VSCode
MIT License
1.58k stars 168 forks source link

Add Operations to Debug Console #388

Open ZachIsAGardner opened 2 years ago

ZachIsAGardner commented 2 years ago

Godot version

3.4.4.stable

VS Code version

1.68.1

Godot Tools VS Code extension version

1.3.1

System information

Windows 10

Problem statement

It's not possible to do various operations in the Debug Console after hitting a breakpoint.

See here for all the different operations possible: https://docs.godotengine.org/en/stable/tutorials/scripting/gdscript/gdscript_basics.html

For example if you hit a breakpoint in a Node2D script you might want to change the position of that Node2D.

So in the Debug Console you would type something like:

position.x = 10

You can set some values through the Inspector, but some types don't work. See: https://github.com/godotengine/godot-vscode-plugin/issues/383

This proceeds this issue: https://github.com/godotengine/godot-vscode-plugin/issues/381 Of which I have a proposed PR for: https://github.com/godotengine/godot-vscode-plugin/pull/387

Proposed solution

Using the existing infrastructure communicating between the extension and Godot we can implement various operations.

In VS Code if you run:

Mediator.notify("changed_value", [
    object_id,
    variable_name,
    value,
]);

That will go over to the Godot Engine and hit the following function in script_debugger_remote.cpp:

void _set_object_property(ObjectID p_id, const String &p_property, const Variant &p_value);

So it's merely a matter of understanding how to format the values properly for all the different types.

ZachIsAGardner commented 2 years ago

Operators

Setting Variables

Built-In Types

Vector Built-In Types

Engine Built-In Types

Container Built-In Types

thoraxe commented 1 year ago

Question about this enhancement: I see that Dictionary is unchecked.

Is the lack of this enhancement why doing some_dictionary.keys() in the debug console in vscode reports null?

atirut-w commented 1 year ago

Is the lack of this enhancement why doing some_dictionary.keys() in the debug console in vscode reports null?

I am not involved with this PR but I doubt so, since it runs a function and shows the return value.