Basic Program Structure
Part of the Fundamentals section of Coddy's GDScript journey. Lesson 4 of 92.
Every program in this course has the same frame:
extends Node
func _ready():
print("Hello, Coddy!")extends Node is the first line of the script. In Godot, a game is built from nodes, and this line makes the script a node.
func _ready(): defines the function Godot calls when the node is ready. Your program starts there, and its statements run from top to bottom.
The colon (:) at the end of func _ready(): starts a block. Every statement inside the block is indented by one level. Godot indents with tabs; use the same indentation on every line of a block.
GDScript does not need a semicolon at the end of a statement. Each statement goes on its own line.
Challenge
BeginnerThis program has two mistakes in its structure, so it does not run. Fix it so it prints:
Ready!
Let's go!- Add the missing colon at the end of
func _ready() - Indent both
print()lines by one level
Try it yourself
extends Node
func _ready()
print("Ready!")
print("Let's go!")
This lesson includes a short quiz. Start the lesson to answer it and track your progress.
All lessons in Fundamentals
4Operators Part 1
Arithmetic OperatorsInteger DivisionModulo OperatorArithmetic ShortcutsRecap - Simple MathComparison Operators10Functions
Declare a FunctionArgumentsReturnReturn TypesRecap - Sigma FunctionRecap - Validation FunctionDefault Values5Operators Part 2
Logical Operators Part 1Logical Operators Part 2Recap - Simple LogicLogical Operators Part 3Ternary OperatorPractice on your own: Online GDScript compiler