godot-d ~master (2021-09-08T21:50:27Z)
Dub
Repo
Differences
godot
docs
Differences from GDScript
GDScript
D
Variables
Instantiation:
var n = Node.new()
auto
n
=
memnew
!
Node
;
Deletion:
n.free()
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.as
!
Node2D
)
// null if n doesn't inherit Node2D
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.math
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.isPowerOf2
?
x
:
x.nextPow2
PI
pow
rad2deg
x
*(
180
/
PI
)
round
sign
sgn
sin
sinh
sqrt
tan
tanh
Algorithms
in
global scope
in
std.algorithm
clamp
max
min
Other functions
in
global scope
assert
assert
keyword
load
ResourceLoader.load
preload
not usable from D
print
godot.d.output.print
Constants and enums
Globals in
global scope
in
godot.globalconstants
Class constants:
Material.RENDER_PRIORITY_MAX
Material.Constants.renderPriorityMax
Meta
Source
See Source File
godot
docs
Articles
Differences
Memory management
Differences from GDScript