+3 votes

Will GDScript differ largely in Godot compared to 2.1?

in Engine by (24 points)

2 Answers

+6 votes
Best answer

Not very much on the language itself, but a few things will:

Instead of get_pos(), you'll be able to simply write position. Same for other things that were "properties" on nodes but that needed get_ and set_ to be read and changed.

_process, _fixed_process, _input etc will be called by default if they are present in the script, no need to explicitely set_process(true) etc anymore.

Dictionaries will be sorted by key insertion order when using a for loop to iterate over them. So I guess if you load some JSON you will get keys in the same order as encountered in the JSON file. While I don't like this (due to performance hit even when you don't need it) it can come handy in several cases.

A more efficient syntax to iterate between 0 and N:

for i in 10: # same as for i in range(0, 10)
    print(str(i))

range was creating an array behind the scenes, the new syntax does it without.

Also, a lot of classes and function names will change (but that goes beyond GDScript). For a more detailed list of compatibility breakage, you can have a look at this doc https://docs.google.com/spreadsheets/d/1SqLGKpF5B5KzYnY2JzuuP71tsR8WeXZn1imMvHkoKDc/edit#gid=0

by (27,170 points)
edited by

Dictionaries will be sorted by key insertion order when using a for loop to iterate over them. So I guess if you load some JSON you will get keys in the same order as encountered in the JSON file.

nice, i didnt like doing that by hand

+2 votes

Some of classes and functions will be renamed or deprecated.
And there will be enhanced script features.

Take a look at Juan's twitter.
https://twitter.com/reduzio

by (9,511 points)
Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to webmaster@godotengine.org with your username.

Categories