How can I learn how to migrate old GDscript code to new Godot engines?

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By GodotUser

Hello,

Could you please point me in the right direction to find the resources which will help me migrate old GDscript code to a newer version. (I am new to coding)

Example, I did a tutorial on YouTube to “Make a Space Shooter” and the instructor used Godot 2.x, I wish to convert it to a newer Godot engine and make changes. I could not find much info on the errors I am encountering and wish to learn how to do the migration.

I often find tutorials which are not using the latest Godot version and wish to migrate the code to one of the newer Godot engines.

Some conversions are easy, ie. get_pos = get_position but others more cryptic like func find_node(node):
Function signature doesn’t match the parent. Parent signature is: ‘Node find_node(String, bool=default, bool)’

Reference: Make a Space Shooter Game in Godot
URL: https://www.youtube.com/watch?v=EteQMVK2joI

Also, would using GDNative code like C, C++, C# be a decent workaround?

Thanks for any advice you can give,
GodotUser

:bust_in_silhouette: Reply From: Jowan-Spooner

For 2.x to 3
I have found this: Migration notes Godot 2 → Godot 3 (found here)

Basically the the most important change was the way of how to access variables and nodes:

2.x:  get_node("NodeName").get_position()
      get_node("NodeName").set_position(new_position)
3.x:  $NodeName.position

For 3.0 → 3.1:
See this question for more information:
Is there anything special to know to migrate a project from 3.0 to 3.1?

If you have more time you can look at the release-post. The biggest change for gdscript was of course optional typing.

Hope that gave you some hints,
Jowan-Spooner

Thanks for the information.

I changed the first find_node to find_parent as seen below:

func find_parent(node):
return self.main_node.find_node(node)
pass

  • not sure why the author chose to use pass in addition to code in the function, I left it as is. FYI, * these early issues I hit are in the utils.gd provided here.

My change above “appeared” to resolve the issue , then hit another issue:
var main_node setget , _get_main_node
var view_size setget , _get_view_size
var mouse_pos setget , _get_mouse_pos

Still researching it. =D

I just bought the Udemy course “Discovering Godot…” so I can learn more about how gdscript works =D

GodotUser | 2019-05-14 23:31

:bust_in_silhouette: Reply From: jospic

if you haven’t done it yet take a look here:

Regards.
-j