0% found this document useful (0 votes)
586 views1 page

GD Script Notebook

The document discusses functions in code, explaining that variables inside functions cannot be accessed outside of them, parameters define values when calling functions, and the % operator divides numbers and returns the remainder. It also mentions that using return will stop a function from running any additional code.

Uploaded by

Koala Krush
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
586 views1 page

GD Script Notebook

The document discusses functions in code, explaining that variables inside functions cannot be accessed outside of them, parameters define values when calling functions, and the % operator divides numbers and returns the remainder. It also mentions that using return will stop a function from running any additional code.

Uploaded by

Koala Krush
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd

Runs as soon at the script gets loaded:

func _ready():

Variables inside a function cannot be accessed by things outside of it

If you pass a parameter, the value of that parameter will be defined when you call
the function:
extends Node

var number = 5

func _ready():

add(number, 10)

func add(a, b):


var result = a + b
print(result)

% operator: Divides 2 numbers and gives you the remainder:


func _ready():
# print the string hello world to the output window
# print(message)

operator(10, 3)

func operator(a, b):


var result = a % b
print(result)

(3 goes into 10 3 times and there is 1 left over)

return:
not going to run anything else after that

You might also like