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!
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.
Like Python, GDScript uses indentation blocks.
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
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
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.