All language subtitles for 4. GDScript Intro Functions

af Afrikaans
ak Akan
sq Albanian
am Amharic
ar Arabic
hy Armenian
az Azerbaijani
eu Basque
be Belarusian
bem Bemba
bn Bengali
bh Bihari
bs Bosnian
br Breton
bg Bulgarian
km Cambodian
ca Catalan
ceb Cebuano
chr Cherokee
ny Chichewa
zh-CN Chinese (Simplified)
zh-TW Chinese (Traditional)
co Corsican
hr Croatian
cs Czech
da Danish
nl Dutch
en English
eo Esperanto
et Estonian
ee Ewe
fo Faroese
tl Filipino
fi Finnish
fr French
fy Frisian
gaa Ga
gl Galician
ka Georgian
de German
el Greek
gn Guarani
gu Gujarati
ht Haitian Creole
ha Hausa
haw Hawaiian
iw Hebrew
hi Hindi
hmn Hmong
hu Hungarian
is Icelandic
ig Igbo
id Indonesian
ia Interlingua
ga Irish
it Italian
ja Japanese
jw Javanese
kn Kannada
kk Kazakh
rw Kinyarwanda
rn Kirundi
kg Kongo
ko Korean
kri Krio (Sierra Leone)
ku Kurdish
ckb Kurdish (Soranî)
ky Kyrgyz
lo Laothian
la Latin
lv Latvian
ln Lingala
lt Lithuanian
loz Lozi
lg Luganda
ach Luo
lb Luxembourgish
mk Macedonian
mg Malagasy
ms Malay
ml Malayalam
mt Maltese
mi Maori
mr Marathi
mfe Mauritian Creole
mo Moldavian
mn Mongolian
my Myanmar (Burmese)
sr-ME Montenegrin
ne Nepali
pcm Nigerian Pidgin
nso Northern Sotho
no Norwegian
nn Norwegian (Nynorsk)
oc Occitan
or Oriya
om Oromo
ps Pashto
fa Persian
pl Polish
pt-BR Portuguese (Brazil)
pt Portuguese (Portugal)
pa Punjabi
qu Quechua
ro Romanian
rm Romansh
nyn Runyakitara
ru Russian Download
sm Samoan
gd Scots Gaelic
sr Serbian
sh Serbo-Croatian
st Sesotho
tn Setswana
crs Seychellois Creole
sn Shona
sd Sindhi
si Sinhalese
sk Slovak
sl Slovenian
so Somali
es Spanish
es-419 Spanish (Latin American)
su Sundanese
sw Swahili
sv Swedish
tg Tajik
ta Tamil
tt Tatar
te Telugu
th Thai
ti Tigrinya
to Tonga
lua Tshiluba
tum Tumbuka
tr Turkish
tk Turkmen
tw Twi
ug Uighur
uk Ukrainian
ur Urdu
uz Uzbek
vi Vietnamese
cy Welsh
wo Wolof
xh Xhosa
yi Yiddish
yo Yoruba
zu Zulu

Original subtitles

0 Once you start writing code, you will find out that parts of the code repeat themselves and this is 1

normal in programming. 2

In fact, it's the way it happens. When you find these patterns, 3

you can make them reusable by creating a function. 4

A function is a separate piece of code that can be called on demand by specifying its name in the execution. 5

Let's look at the code. 6

So here we have defined a function add(). 7

To create the new function, we need to use the operator func in GDScript and then the name of the 8

function. 9

And we do need to use the parenthesis, but they can be empty or we can specify additional parameters. 10

Don't forget to add the colons after each function implementation. In the function body 11

we can do something with the provided values and in this case we just add them. 12

And we used another operator called return, which will return the final value. 13

And this value can be used in the previous function that called this one. 14

In this case, I'll be saying adding one plus one and then calling this function. 15

This will add these two elements and will give the result to be printed in the console. 16

Keep in mind that now we can use this. 17

Add as many times as we like to add two values. 18

But this can be a move function. 19

This can be a fire projectile function. 20

This can be whatever you want. 21

There is also another type of function called recursive function, and the recursive function is just 22

like a regular function with the one spin that it calls itself in its own body. 23

As you might imagine, if you've seen the Inception movie, this can lead to infinite execution. 24

And we don't want that. 25

So remember, if you ever implement a recursive function, then you need to make sure that you have 26

something called the exit condition. 27

So the exit condition is usually an IF statement that checks a final condition to break this recursive 28

pattern. 29

This is important to prevent the function running indefinitely. 30

Recursive functions are useful in some particular algorithm implementations in this course.

Can't find what you're looking for?
Get subtitles in any language from opensubtitles.com, and translate them here.