+3 votes

Will GDScript differ largely in Godot compared to 2.1?

asked Jan 12, 2017 in Engine by aggsol (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

answered Jan 12, 2017 by Zylann (15,096 points)
edited Jan 12, 2017 by Zylann

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

answered Jan 12, 2017 by volzhs (7,893 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.