Add Operations to Debug Console
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.
Operators
- [x] Subscription: x[index]
- [x] Attribute Reference: x.attribute
- [ ] Function call: foo()
- [ ] Instance type checker: is
- [ ] Bitwise NOT: ~
- [ ] Negative / Unary negation: -x
- [x] Multiplication: *
- [ ] Division: /
- [x] Remainder: %
- [x] Addition: +
- [x] Subtraction: -
- [ ] Bit shifting: << >>
- [ ] Bitwise AND: &
- [ ] Bitwise XOR: ^
- [ ] Bitwise: |
- [x] Comparisons: < > == !+ >= <=
- [ ] Content test: in
- [ ] Boolean NOT: ! not
- [ ] Boolean AND: and &&
- [ ] Boolean OR: or ||
- [ ] Ternary if/else: if x else
- [ ] Type casting: as
- [ ] Assignment: = += -= *= /= %= &= |= <<= >>=
Setting Variables
- [ ] Setting all variables types
- [ ] Setting variable to math equation
Built-In Types
- [x] bool
- [x] int
- [ ] float
- [x] String
Vector Built-In Types
- [ ] Vector2
- [ ] Rect2
- [ ] Vector3
- [ ] Transform3D
- [ ] Plane
- [ ] Quat
- [ ] AABB
- [ ] Basis
- [ ] Transform2D
Engine Built-In Types
- [ ] Color
- [ ] NodePath
- [ ] RID
- [ ] Object
Container Built-In Types
- [ ] Array
- [ ] Dictionary
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?
Is the lack of this enhancement why doing
some_dictionary.keys()in the debug console in vscode reportsnull?
I am not involved with this PR but I doubt so, since it runs a function and shows the return value.