Home Blog Gaming

Introduction to GDScript

Godot Tutorials > Introduction to GDScript
GDScript is a scripting language created specifically for the Godot Game Engine. It is based on Python and designed to be:
  1. Easy for Beginners
  2. Well suited for the Godot Editor
  3. Aligned with Game Developers' needs

If you are familiar with Python, you will find GDScript super easy to learn. If you are not familiar with Python, you will still find GDScript easy to learn. It is a straight forward language with intuitive syntax. I recommend using Godot's text editor for easy debugging and syntax highlighting. Godot Game Engine, GDScript, and the Godot editor are built to work together harmoniously.

Download Godot Editor Here!

Scripting Language

A scripting language is a programming language that does not need to be compiled. Compilers work as a translator between your source code and the hardware. In contrast, scripting languages use a run-time interpterator. The programmer is not involved in the translation processes. The interpretation occurs as the code is executed.

Indentation Blocks

Like Python, GDScript uses indentation blocks. Indentation, not punctuation! Many traditional scripting languages use semi-colons and brackets to show the end of code lines and code blocks. Instead, GDScript uses indentation and line breaks.

Let's look at a GDScript example:
var paladinSkills = [20,5,15,18,5,10]

# Offensive Function
func offensiveScore (skillArray):
  var baseScore = skillArray[1] + skillArray[2] + skillArray[4] - skillArray[5]
  var intelligence = (skillArray[0] * .01) + 1
  var spirit = (skillArray[3] * .015) + 1
  var offensive = 1 + baseScore * intelligence * spirit
  var adjust = offensive / 5
  return adjust

# calculate offensive score
var bigOs = offensiveScore(paladinArray)

The code above includes a user defined function (a block of code written by a programmer that performs a specific task). The function is named offensiveScore. All the code that is included in the function is indented two spaces. The interperter knows when the function has ended because the code is no longer intented two spaces. The variable called bigOs aligns with the first line declaring our offensiveScore function.

If you are a bit confused, do not worry. As the tutorials progress the concepts will become much more clear.


Look at the example above. Lines of code that begin with a # are called comments. Comments are code that doesn't execute. They are notes that make your code readable.

Over time programmers often forget how their code works. Comments remind you. Furthermore, it is common for other programmers to read your code. This may be because you are working on a team, your code is passed on to someone new, or possibly you are asking for help. In any instance, your comments will make your code easier to read and debug.

Support Coding Commanders

Because it is crucial to achieving upward economic mobility, Coding Commanders believes everyone should have access to free quality STEM education. My tutorials explain complex concepts in plain English using relatable examples. No previous mathematics or technical knowledge required!

Linux Gaming Blog - Coding Commanders
Palm Beach Techie - Diverisity in Tech
Linux Gaming King Hatnix on Twitch
Linux (Ubuntu)+ NodeJS + Postgres
LAMP - Linux, Apache 2, MySQL, PHP
Sexy Linux T-shirt
Twitch: daisychaincosplay Live Coding!!!
Coding Commanders YouTube
Coding Commanders Twitter
Learn HTML on Linux with Commander Candy
Previous Lesson | Next Lesson