Title here
Summary here
GDScript has various value types including strings, integers, floats, booleans, etc. Here are a few basic examples.
extends Node
func _ready():
# Strings, which can be added together with +.
print("gd" + "script")
# Integers and floats.
print("1+1 =", 1 + 1)
print("7.0/3.0 =", 7.0 / 3.0)
# Booleans, with boolean operators as you'd expect.
print(true and false)
print(true or false)
print(not true)
To run this script in Godot:
The output will be:
gdscript
1+1 = 2
7.0/3.0 = 2.333333
false
true
false
In GDScript, print
is used instead of fmt.Println
. The language doesn’t require explicit typing, making it more concise than statically typed languages. Boolean operators in GDScript are written as and
, or
, and not
instead of symbols.
GDScript is dynamically typed, so you don’t need to declare variable types explicitly. It’s designed to be easy to use and integrate well with the Godot game engine.