godotengine / godot

Godot Engine – Multi-platform 2D and 3D game engine
https://godotengine.org
MIT License
89.56k stars 20.28k forks source link

`update()` is not renamed to `queue_redraw()` for `Node2D`(or anything that inherits `CanvasItem`) #67003

Open Anutrix opened 1 year ago

Anutrix commented 1 year ago

Godot version

v4.0.beta.custom_build [0c23a2cfe]

System information

Windows 11 Pro 22H2 64 bit

Issue description

update() is not renamed to queue_redraw() for Node2D(or anything that inherits CanvasItem) after https://github.com/godotengine/godot/pull/64377.

Additional info: I thought of making a simple MR to add it myself in ProjectConverter3To4 but I wasn't sure simply if replacing update() function in all script files will work since other classes also have update() method. image

Steps to reproduce

  1. Import Bullet Shower demo from https://github.com/godotengine/godot-demo-projects.
  2. Convert full project.
  3. Try running it.
  4. Observe Parse Error: Function "update()" not found in base self error.

OR

  1. Import Bullet Shower demo from https://github.com/godotengine/godot-demo-projects 4.0-dev branch.
  2. Try running it.
  3. Observe Parse Error: Function "update()" not found in base self error.

Minimal reproduction project

Bullet Shower demo from https://github.com/godotengine/godot-demo-projects

KoBeWi commented 1 year ago

The project converter has no information about the script type, it operates only using text. Thus update() can't be auto-converted, because it would change methods that shouldn't be changed.

Mickeon commented 1 year ago

It would take a lot of effort to have the converter discern type by context, and therefore being able to appropriately convert update where needed. In the end it may be worth it, but there's so many things to focus on.

Anutrix commented 1 year ago

The project converter has no information about the script type, it operates only using text. Thus update() can't be auto-converted, because it would change methods that shouldn't be changed.

Exactly.

It would take a lot of effort to have the converter discern type by context, and therefore being able to appropriately convert update where needed. In the end it may be worth it, but there's so many things to focus on.

But the files are converted one at a time so reading first non-empty line to see what type it extends should work, right? Then, we can make type-specific method/property name conversions.

Also, we would need to inform the user someway if conversion is not possible. I had to dig the repo and file commit history to find out what update method was renamed to.

Calinou commented 1 year ago

What can be done in those situations is to add a command at the end of the line, like this:

func _ready():
    $Something.update()  # 3to4: `update()` may have to be renamed to `queue_redraw()`.