Module godot.docs.differences
Differences from GDScript
| GDScript | D | |
|---|---|---|
| Variables | ||
| Instantiation: | var n = Node | auto n = memnew!Node; |
| Deletion: | n | memdelete(n); |
| Reference-counting: | All vars inheriting Reference are automatically ref-counted | Ref!ArrayMesh rc = memnew!ArrayMesh; // explicit Ref!T wrapper increments ref-count |
| Dynamic typing: | All vars are dynamically-typed | Variant v; // accepts any Godot-compatible type |
| Checking inheritance: | if n is Node2D: | if(n |
| Scripts | ||
| Inheritance: | class MyNode extends Node: | class MyNode : GodotScript!Node { } |
| Export method: | func _ready(): # automatically exported | @Method void ready() { } |
| Export property: | export var text = "asdf" | @Property String text = gs!"asdf"; |
| Global variables: | Autoloaded singleton nodes only | Autoloaded singleton nodes; alternatively, D variables declared outside any class, or as static inside a class |
| Naming conventions | ||
| Class/node: | PascalCase | PascalCase |
| Function/variable: | snake_case | camelCase |
| Constant/enum: | ALL_CAPS | camelCase |
| Math | in global scope | in std |
| abs | ||
| acos | ||
| asin | ||
| atan | ||
| atan2 | ||
| ceil | ||
| cos | ||
| cosh | ||
| deg2rad | x*(PI/180) | |
| exp | ||
| floor | ||
| fmod | ||
| is_inf | isInfinity | |
| is_nan | isNaN | |
| log | ||
| nearest_po2 | x | |
| PI | ||
| pow | ||
| rad2deg | x*(180/PI) | |
| round | ||
| sign | sgn | |
| sin | ||
| sinh | ||
| sqrt | ||
| tan | ||
| tanh | ||
| Algorithms | in global scope | in std |
| clamp | ||
| max | ||
| min | ||
| Other functions | in global scope | |
| assert | assert keyword | |
| load | ResourceLoader | |
| preload | not usable from D | |
print | ||
| Constants and enums | Globals in global scope | in godot |
| Class constants: | Material | Material |