3. Indentation, lines and comments
# A whole-line comment.
func run() -> int:
var points: int = 5 # A comment after an instruction.
if points > 0:
print("There are points to award.")
return pointsA colon opens a function, branch, loop or class block. Indentation tells Godot which lines belong to that block. There is no end keyword. Use one consistent indentation style; the editor’s Tab key is a sensible default.
# begins a comment. ## is used for documentation comments in Godot’s documentation workflow. // is not a GDScript comment marker. Triple-quoted text is a string, not a separate block-comment system.
func run() -> void:
await ShowMessage({
"text": "The workshop is quiet.",
"duration": 2,
"blockInput": false
})Unlike PCA Script, GDScript allows a call, array or dictionary to continue across lines inside brackets. Use this to keep options readable. A line with only pass is a valid empty function body while you are building the rest.
