|Topic was automatically imported from the old Question2Answer platform.
It’s all to do with Static Typing (a 3.1 feature).
Grey lines numbers indicate Unsafe Lines, where the editor doesn’t know if the code will work at runtime. Green line numbers indicate that you have used Static Typing to help casting. See the section headed Safe lines on this page
Godot 3.1 introduced Static Typing, which you can read about here
What that means is that, when creating a variable, you can tell Godot whether it’s an integer, float, text, vector, class etc. The type can be a built in, a core class or even one of your own custom classes. Although I said that this works for variables, it also works for parameters, function return values etc.
You don’t have to use Static Typing and can carry on just letting Godot use Dynamic Typing, if you wish.
One of the things about types is that, if you try and convert one type to another (eg integer to float), It may or may not be a “safe” conversion. The Godot team call that conversion “casting”.
Quite often, Godot won’t know until runtime whether the casting can be done, since it depends on what you put in a variable. In such cases, the editor warns you that the casting is unsafe. Unsafe lines are those defined as those where there may be a casting problem when you run the code and the line number is grey. If you explicitly state types, then the casting will work and the line number is green.
You can chose to turn safe lines on/off or change their colour in the editor settings (Text Editor –> Highlights)
Lines with green number means the editor’s script analysis succeeded in detecting the type of all things in that line, so it can give accurate completion and checks.
When the line number is grey, it means the editor was not able to fully analyse the line (i.e it doesn’t know in advance the type of some variable in it) so completion may not be 100% accurate.
This is the concept of “Safe Lines”, see Optional typing in GDScript