godot-vscode-plugin icon indicating copy to clipboard operation
godot-vscode-plugin copied to clipboard

Add Operations to Debug Console

Open ZachIsAGardner opened this issue 3 years ago • 3 comments

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 avatar Jun 21 '22 20:06 ZachIsAGardner

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

ZachIsAGardner avatar Jun 21 '22 20:06 ZachIsAGardner

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?

thoraxe avatar Feb 22 '23 02:02 thoraxe

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.

atirut-w avatar Feb 23 '23 11:02 atirut-w