Godot is able to do much more than Scratch, but some things that were simple in Scratch are more complicated in Godot. This guide is intended to help with those things. Most of these Godot codes should behave the same way they do in Scratch, but ultimately it will be best not to try and do everything the same way you did it in Scratch. There are usually a lot of different ways to achieve the same result in Godot – which one to use depends on your specific project. So, these are just suggestions.

Motion

ZqtQwPr0WZw4Yaz5valrrpvlE9RzKHAnZqm8PFNj+gd0I461NMNqAyD00ZnzX9ryLUxaM313YzYUQMeSUFlGHz0pRtytQ8np+LonowK6uRUDAqNB6TZK7rxdlZDniNCM1m83Izj0WoQD58K62drsOKjFjo6QmhlEGkamUwGDNOcZ45Iva2mQGMYBjRNH4k5Kbb1P1qwwaBtneWuAAAAAElFTkSuQmCC

position += 10*transform.x

0u4PYDMZQ9MAAAAASUVORK5CYII=

rotation_degrees += 15

zTWb0HP7gsoAAAAASUVORK5CYII=

rotation_degrees -= 15

ScHlIrxH35wm2VJEZdRAAAAAElFTkSuQmCC

position = Vector2(randf() * 1024, randf() * 600)

iAAAAAElFTkSuQmCC

position = get_global_mouse_position()

MOV8Wuah4CWRii8UzfwL9UyuCveZ7dPoNLt8Kwxt4VVFdmoXCRVv7EkRg0xkM2P3om9pfKuyzbMF0e63ujSRW9r2IeMDuh7pKSX3mJOx3InVvBDEjyCpv+vsQesyVLSfpMjK47SjOuS1qICiTyWD4RhhHxkNoH4tBNfKCE40piiPGAGbub9b94hsBQf8nYXUzhXkXg3lXjJOF57Vbxt+MtP7IQuT8B5PXJ1KRotDjAAAAAElFTkSuQmCC

position = $"../Sprite".position

wOlwtMBBTzH7QAAAABJRU5ErkJggg==

position = Vector2(0,0)

wAUcgtQbxgU1QAAAABJRU5ErkJggg==

You can set up a glider in the script using this code:

signal glide_completed

var velocity = Vector2.ZERO

var glide_time = 0

func _process(delta):

position += delta*velocity

glide_time -= delta

if glide_time < 0:

velocity = Vector2.ZERO

emit_signal("glide_completed")

And then put the code below in func _ready() to glide 1 secs to a random position:

glide_time = 1

velocity = (Vector2(randf() * 1024, randf() * 600) - position) / glide_time

yield(self,"glide_completed")

B8VeFMJDYOrowAAAABJRU5ErkJggg==

For this to work, you first need to set up the glider (see above).

glide_time = 1

velocity = (get_global_mouse_position() - position) / glide_time

yield(self,"glide_completed")

Ttz8ShTzvggnnsDWgXeQyNFBfNChSEUjCixS0fwPd7lo+BiODzoAAAAASUVORK5CYII=

For this to work, you first need to set up the glider (see above).

glide_time = 1

velocity = ($"../Sprite".position - position) / glide_time

yield(self,"glide_completed")

gXaxxEisWEoAAAAASUVORK5CYII=

For this to work, you first need to set up the glider (see above).

glide_time = 1

velocity = (Vector2(0,0) - position) / glide_time

yield(self,"glide_completed")

+LKB9aXTXfJ3ArlMZWMCWJL7pb94ajNNAAlOPFf3hceOo7bH1bAAAAAElFTkSuQmCC

rotation_degrees = 90

3QdM64XTf9UAAAAASUVORK5CYII=

rotation = position.direction_to(get_global_mouse_position()).angle()

YG9lF5RtH4D3cvyn47NlGoAAAAAElFTkSuQmCC

rotation = position.direction_to($"../Sprite".position).angle()

Hh4SvlntxQKBSQz+cPxJmHxZbizznxRbLwsRlJBdc36z7hZpD6gJojqn8BLsqEBYA0xMYAAAAASUVORK5CYII=

position.x += 10

4PSVYYjkSR3gtkZPIeqLqF72nBTfI5D9WCKWkdofkkwAAAABJRU5ErkJggg==

position.x = 0

ABIeLJ6cgSeKAAAAAElFTkSuQmCC

position.y += 10

gy2qZSMrUX0AAAAASUVORK5CYII=

position.y = 0

U9oEc4voQsYAAAAASUVORK5CYII=

if position.x < 0 or position.x > 1024:

transform.x.x *= -1

if position.y < 0 or position.y > 600:

transform.x.y *= -1

gWa7kWi0kahJgAAAABJRU5ErkJggg==

Make the moving object a RemoteTransform2D and have the Sprite node separate.

In the Inspector for the RemoteTransform2D, choose the Sprite as Remote Path. In Update, uncheck Rotation and Scale.

This code goes in the process method for the moving object:

get_node(remote_path).flip_h = (get_node(remote_path).rotation_degrees > 90)

At4MpGD18HAE1+EIyNPnX4PFncfr7sco6Hx5AEE0imGvX5x+lMXAV0kcHpvHocBjWY5eSCA0kUQ6x3c8eGL7QO8ZJbYFJDqxLfgflCDiV3CX1ogAAAAASUVORK5CYII=

Make the moving object a RemoteTransform2D and have the Sprite node separate.

In the Inspector for the RemoteTransform2D, choose the Sprite as Remote Path. In Update, uncheck Rotation and Scale.

AqqhVLZOPJCpAAAAAElFTkSuQmCC

Make the moving object a RemoteTransform2D and have the Sprite node separate.

In the Inspector for the RemoteTransform2D, choose the Sprite as Remote Path. In Update, uncheck Scale.

1AAAAAElFTkSuQmCC

position.x

F8fQfX7yThonOwURJcgfeWB2YqeEaBnRIw4lvHwhPBMEZTIPavKKsFzP7O4co3mxj0JnGe4XBxOofRyWxP6OJ0DkMsh4+oFK7ObmH8xzQeLwtQ1D1T8R3qJTAv7mItJSG6VsTSaqEn9CxWwMuNElI52bAEOgriJOoURLdBqKoKRVGwt2euRq229T9JMYvKqCcxywAAAABJRU5ErkJggg==

position.y

QQK3XgQ0UY1EwAAAABJRU5ErkJggg==

rotation_degrees

Looks

AzL+jLG5gn2wAAAAAElFTkSuQmCC

Add a Label as a child node, resize and position it as desired.

$Label.text = "Hello!"

yield(get_tree().create_timer(2), "timeout")

$Label.text = ""

jWJ4LYelRQFIvnoZBO5pbB690fXpDrYX6D7oTmYxCVc+HAAAAAElFTkSuQmCC

Add a Label as a child node, resize and position it as desired.

$Label.text = "Hello!"

vuJCnfghb3AAAAABJRU5ErkJggg==

You could follow the instructions above for say. To get a picture (like a speech bubble) behind the text, you need a TextureRect or ColorRect which you can show() and hide() in your code.

Godot is also able to print messages to the output log:

print("Hmm...")

6wNrx6UdquKVFPW+zQpfxzW9yGsvuOP7V8G8WhK9IEfCfDjHIPXXP4DFx7ZiULupn8AAAAASUVORK5CYII=

8BZmOO8G0ezaEAAAAASUVORK5CYII=

texture = load("costume2.png")

fuDUIFwcwAAAAAElFTkSuQmCC

Use an AnimatedSprite instead of a normal Sprite. In the Inspector, set Frames to New SpriteFrames, then click on SpriteFrames to edit it. Drag images into the Animation Frames area. You can set the animation Speed and choose whether or not it will Loop (repeat again and again). If you want the animation to start when the game starts, make sure to tick the Playing box in the Inspector. You can have more than one animation, each with its own name and frames.

frame = (frame + 1) % frames.get_frame_count("default")

B81yi8I56ZknwAAAABJRU5ErkJggg==

get_tree().change_scene("backdrop1.tscn")

Switching scenes in Godot isn’t exactly like switching backdrop in Scratch. Most importantly, the objects from the first scene will disappear and the objects from the second scene will appear. To make an object stay, right click the node and choose Save Branch as Scene. Then remove it from the scene and instead add it to the AutoLoad list (Project menu, Project Settings, AutoLoad tab, click the folder icon, then click Add).

2v5iRLWlvcsB2A7qIqiYGVxF8K56sBHzGfPKgicFyGlD0xJwI4y5ZOf5adFhK+mIYyLCPhzhopey2P+Vhabn7Wb+zDJ1O+o9qUW9qSmsUraz2OGUe7HacegPzWv8h444nVTAAAAAElFTkSuQmCC

7Yrwt3OADrYTeej6nf5EN5T2RLkoR0SoRvYR1+94YuQe9G1U94J0NfereD+A8iz5yDR2cKngAAAABJRU5ErkJggg==

scale *= 10 / (scale.x * texture.get_width()) + 1

1D4HydUZ5ELH16mAAAAAElFTkSuQmCC

scale = Vector2(1,1)

vJuouk8GoBd2e07qTyyOwlkLQs00lLPMYQQbjZcIeTMx4pWiI8Ds7O8jlcsjn8w1vACuLlaWlrP8DLWqXebKsRMAAAAAASUVORK5CYII=

modulate.s = 1

modulate.h = wrapf(25 / 200.0 + modulate.h, 0, 1)

AY6OYG1M1okQAAAAAElFTkSuQmCC

modulate.a = clamp(modulate.a - 25 / 100.0, 0, 1)

lww3dApBxOmn7GwVdMAI7RXEuy8qei+M9iXPckUHqHlh7K8RUTAG9Rd1Mv2TDgZASrSwndE0DpLVp+iszT+RhYc1r1Tdzsw0XMHgsg7C7ovvKU3kOTxx4tfRYCN+EGOx7A7KiPiOO8HzcvebGxktZ9xSm9iabP6UqG80iEc2QiOc1iUQ4n9MFylJ6CCkvpKf4HvY30edUytz0AAAAASUVORK5CYII=

modulate.s = 0

GOjuIrPEAAAAAElFTkSuQmCC

modulate.a = 1

NQn+873oRR11AvXngwqyHsqw64AjW8XJMAHYdomiaW4gUo3hIik2ZP8ELjOgKfZKCuVR0v3i2y5RUoaw92MP9tGnNfpxH6VBVq7qsMfry0jUKm5njhbpKt77GpVnTUaw2h9Lr4GX6pwfUfTDY1pLDUZlEAAAAASUVORK5CYII=

modulate = Color.white

YAAAAASUVORK5CYII=

show()

capO5rT5CyeKLlr6uQ9CAAAAAElFTkSuQmCC

hide()

ArsmWga2wMEcAAAAAElFTkSuQmCC

You can do this by setting z_index to a higher number than all the other nodes in the scene (but never higher than 4096).

Dl4kXkI7nlUnkde8wo0XyGcbiP6l4P54mo8EBAAAAAElFTkSuQmCC

You can do this by setting z_index to a lower number than all the other nodes in the scene (but never lower than -4096).

MBZ9idp+Vk32bwZL9rV6L22jp4rsemrkWPsgQ4mnWPHbbKwRIP9nUKWfQUrNMu+4ncS4BXBaMA4LwAAAABJRU5ErkJggg==

z_index += 1

fpsCdywKq5QnUOl3wKmzMA+5kQwLvyyBwdhNWvLayh+mY3D90YuJ0x6YTz4XxXlmFVOXAoitZdrecMbepKXvac3n2ajN6GzYi4kZe4qfAJg5ctHRTugnAAAAAElFTkSuQmCC

z_index -= 1

yg39PYegNpLxSwc0w1aYv3Fi7bkPtn+jnPq36Rdv49E04pFDQW2k0vchuEp4C1tQUf8DNMVU8gcC2xEAAAAASUVORK5CYII=

frame

r8ZYgxluCVfdDbg1ddooyFa0M4uWDQEHIkocDXzz0QX+jPmBPXA3jXrMX4y0BjLX4alqjVwIYanLCLNhp1HYF8NSyd7pToBzHYfO3MPR9trrYp9ZRSWhaY6DbaltaxcGbSKbb9qG5acPac+kToCVBcxyHxEEKz+f2YLrFgu70QUcl+H3rMhf2DckkdQYmVRp66hAaZQDGWyyezbgRCydLQi4LNFEslMSmNYQnBjem+m2ge15h5mMWxtuOhiqsbwdY0D07mOq34+dxN9ZfBhH2J8ridmLQBeFHkoiFDxuquMqL2oqBbqh29D+85w5Q1dzB3QAAAABJRU5ErkJggg==

texture.resource_path

tH1pC7QAAAABJRU5ErkJggg==

Scenes in Godot don’t have numbers

cFqE8Wf5XYQAAAAASUVORK5CYII=

get_tree().current_scene.filename

lN4D0S4HbxsPA4BrDsBPiIhna79Wv8AoBoB0pHCLyQAAAAASUVORK5CYII=

scale.x * texture.get_width()

Sound

ApSLuy2vLb68AAAAAElFTkSuQmCC

Add an AudioStreamPlayer node to the scene. In the inspector, load an audio resource as its Stream.

stream.loop = false

play()

yield(self,"finished")

dEewKnXFQyAAAAABJRU5ErkJggg==

Add an AudioStreamPlayer node to the scene. In the inspector, load an audio resource as its Stream.

stream.loop = false

play()

Z0P3BS8QWjAAAAABJRU5ErkJggg==

You will need to do this for each AudioStreamPlayer

stop()

kJdzqWAi865FPwX8HzBZUeoMOYAAAAASUVORK5CYII=

pitch_scale *= pow(1.06, 10 * 0.1)

AXgdmHQX9NQ2AAAAAElFTkSuQmCC

Use an AudioStreamPlayer2D instead of an ordinary AudioStreamPlayer

position.x += 10 * (max_distance/100.0)

wGCpb8uNxqe5AAAAABJRU5ErkJggg==

pitch_scale = pow(1.06, 0 * 0.1)

jeaQvESzySiUK4rVCIKpUP+B6hWNCWtdU4MAAAAAElFTkSuQmCC

Use an AudioStreamPlayer2D instead of an ordinary AudioStreamPlayer

position.x = 0 * (max_distance/100.0) + 512

aoy9cBX1H1J5UcdgTvt0AAAAAElFTkSuQmCC

Just do both of the lines above.

hKTeeUR+bBwWrvarKduurn6zDNEzB2VcBrkoOkoZlyEOzCHxbOPYL5yrPv0P8QN2uoLPWK0AAAAASUVORK5CYII=

volume_db = linear2db(clamp(db2linear(volume_db) - 10 / 100.0, 0, 1))

MQZFkugsh3OIhvOGLIT2275CTNsloBxMvkXQztKziozj4UAAAAASUVORK5CYII=

volume_db = linear2db( 50 / 100.0 )

pyaGZQODEz02GaUBzPZo4q3hQmDvmv4HPKKu0AKnrQQAAAAASUVORK5CYII=

100*db2linear(volume_db)

Events

BO8qG5XvPhQAAAAASUVORK5CYII=

func _ready():

05vxAhig+bzAAAAAElFTkSuQmCC

func _input(event):

if event is InputEventKey and event.pressed and event.scancode == KEY_SPACE:

wZV7wgA4w9HAAAAAElFTkSuQmCC

Add an Area2D as a child node of the sprite, and add a CollisionShape2D as a child node of the Area2D.

In the Inspector, choose the correct shape, then in the viewport move and/or resize it to fit the sprite.

Select the Area2D node, then in the Node tab, double-click the input_event signal and choose the sprite.

func _on_Area2D_input_event(viewport, event, shape_idx):

if event is InputEventMouseButton and event.pressed:

g+aW8ow2tPeMgAAAABJRU5ErkJggg==

This code will work for any objects that are not AutoLoad scenes:

func _ready():

if (get_tree().current_scene.filename == "res://backdrop1.tscn"):

J0ZgBxD65K+qd5zSe3T4iN8sXIuX4dF8sXykvhaClkj38rv3W9U7TelNFHnedEK4D8E+C8H+Xm0cOuzGnKp3mNK7KPbwcwqlU6iMlJ6BykjpGf4H6W45V8LaMuQAAAAASUVORK5CYII=

Click Audio at the bottom of the screen, click Add Bus, click M to mute the new bus, then add a SpectrumAnalyzer effect.

Add an AudioStreamPlayer node to the scene, set its Stream to New AudioStreamMicrophone, and tick Autoplay.

Enable Audio Input in the Audio section of Project Settings (Project menu, Project Settings, General tab, click Audio in the list on the left then make sure Enable Audio Input is ticked).

signal loudness_updated
var loudness = 0
onready var bus_ei = AudioServer.get_bus_effect_instance(1, 0)
func _process(delta):
    var AudioServer.get_bus_effect_instance(1, 0)
      loudness = clamp(1000*bus_ei.get_magnitude_for_frequency_range(0,10000)[0],0,100)
And then put the code below in func _ready() to wait until the loudness is greater than 10:
while (loudness <= 10):

yield(self, "loudness_updated")

bxITBO6SQAAAABJRU5ErkJggg==

You can set up a timer in the script using this code:
signal timer_updated
var timer = 0
func _process(delta):
      timer += delta
      emit_signal("timer_updated")
And then put the code below in func _ready() to wait until the timer reaches 10:
while (timer <= 10):
      yield(self, "timer_updated")

A8qjD69Sr5BngAAAABJRU5ErkJggg==

In the script for the object sending the message, define the signal:

signal message1

Select the object that will send the message. In the Node tab, double-click the signal name and then choose the object that will be receiving the message. This will add the correct code to your script, which looks something like this:

func _on_Sprite_message1():

XctMOZmyq2kAAAAASUVORK5CYII=

emit_signal("message1")

ovISqPcT1wgoDh6H+ONtRg2sotM8lmJ+wkLBFb+B9khKh1NEx9BAAAAAElFTkSuQmCC

Godot doesn’t do this.

Control

H7V+2Ef7X3AAAAAElFTkSuQmCC

In func _ready or func _input, you can use this code:
yield(get_tree().create_timer(1), "timeout")
But _process runs many times per second so you need to use a timer variable to choose which code to skip when it runs:
var timer = 0
func _process(delta):
      if timer > 0:
            timer -= delta
      else:

B5vKu2gVpasdAAAAAElFTkSuQmCC

for n in 10:

9a8RlXu4yiLQAAAABJRU5ErkJggg==

You can use _process for this because it runs many times per second:
func _process(delta):
But yield doesn’t work in _process, so it’s harder to pause the code. If you want to easily pause code, use _ready:
signal forever
func _ready():
	while true:
		yield(self, "forever")
And then your repeating code goes under the above code. For this to work, set up your _process like this:
func _process(delta):
	emit_signal("forever")

CBSDdXAnEpIAAAAASUVORK5CYII=

if … :

AAAAAElFTkSuQmCC

Godot also has elif (stands for “else if”) which you can put as many times as you like between the if and else.

if … :

else:

XPy9UvDRIAAAAAElFTkSuQmCC

Instead of stopping the loop when a condition is met, Godot keeps repeating as long as the condition is still met.

while … :

qfq0st2PpHWHAEhsiq97eRBacI2RHDCtIlCQJ2ctj4F33a5a3GaDAug9iPfK+6Y23C7olSpIEdu513HUcQsr3BFKeQx1hvU9g1fU9FJbPmd5wO2GIREmSIApVlNlF8JmljlSyy6Y32I4YJpFgM4mCIKBWq0EQhL43gMSS8H9Eho1Mbp8CJgAAAABJRU5ErkJggg==

fAI6cUbPdt1jKK17ec0MGOu7dif2F152FdoX6njoNFoQBAENBqNsY9th7mcPf+ngCPVkWoPvgEXnnzTbsM6CwAAAABJRU5ErkJggg==

There are various options depending which method you want to stop. Call on each object you want to stop it for.

set_process(false)

set_process_input(false)

UbHgsMELzhM8ILzH+AxZ7vX2FUqAAAAAElFTkSuQmCC

HkOdPQAAAABJRU5ErkJggg==

h+b2vIYcnkPjpC1uSkS+RWmQHM+413P+RMQwmAIMJwGACMNzgfxpJ1Gcp6PfRAAAAAElFTkSuQmCC

func _ready():

wEA7PRDhGxEwgAAAABJRU5ErkJggg==

get_parent().add_child(self.duplicate())

wM9KK08WUVlNwAAAABJRU5ErkJggg==

get_parent().add_child($"../Sprite".duplicate())

mgAAAABJRU5ErkJggg==

queue_free()

Sensing

vcjE9DmJgc40FPoXi6Hxx+cU+QgAAAAASUVORK5CYII=

Add an Area2D as a child node of the sprite, and add a CollisionShape2D as a child node of the Area2D.

In the Inspector, choose the correct shape, then in the viewport move and/or resize it to fit the sprite.

This code is actually all on one line but has been shown across multiple lines because there’s not enough space.

if get_world_2d().direct_space_state.intersect_point(get_global_mouse_position(), 32, [], 2147483647, true, true).size() - get_world_2d().direct_space_state.intersect_point(get_global_mouse_position(), 32, [$Area2D], 2147483647, true, true).size() > 0:

wEMYLQfJQJn7AAAAABJRU5ErkJggg==

Godot doesn’t do this, but you could put Area2D objects along the edges of the screen and test whether touching those.

eKSAAAAAElFTkSuQmCC

Both sprites need to have Area2D and a CollisionShape2D or CollisionPolygon2D.

if $Area2D.overlaps_area($"../Sprite/Area2D"):

BZdzplFzmQ2xAAAAAElFTkSuQmCC

Godot doesn’t do this. Instead, put nodes in groups (use the Node tab next to Inspector) and check that.

var overlapping_group = false

for area in $Area2D.get_overlapping_areas():

if area.is_in_group("wall"):

overlapping_group = true

break

if overlapping_group:

GpNTRoIAAAAASUVORK5CYII=

Godot doesn’t do this.

03dIGfjs6A1MfhzY3h1YPj096OXzi1KSpNN1ycjB6BbR7eLS6gvjr43nwy9sl8Xeu37p69SaD+GYK7IuXGFvYwMP4miZNJenx0ib4lSQWt5Rd9MJg1aRJDWmwaroy+j8wkBrV9OIgfQAAAABJRU5ErkJggg==

position.distance_to(get_global_mouse_position())

qNnSv4Z401QAAAABJRU5ErkJggg==

position.distance_to($"../Sprite".get_global_mouse_position())

B3o4VXjxyYV4AAAAAElFTkSuQmCC

Add a LineEdit, and resize and position it as desired. Then set it as invisible by clicking the eye icon.

$"../LineEdit".placeholder_text = "What’s your name?"

$"../LineEdit".show()

yield($"../LineEdit", "text_entered")

$"../LineEdit".hide()

Cigc7hybyeCvCi6Y0HfA3wEYbUU0OcqQAAAABJRU5ErkJggg==

$"../LineEdit".text

vYnx1r67n5O0sPam2rrQrB3BsdQ9P1vZN3WJNrr+rG7y64SsWi5j54x3GfFHmf9lgip1+WozjU+5rXfw0BJ8pU43KhM8UM5nwmWKmfwHMtHWJdVydmgAAAABJRU5ErkJggg==

if Input.is_key_pressed(KEY_SPACE):

r8oLT3NniuUAAAAASUVORK5CYII=

if Input.is_mouse_button_pressed(BUTTON_LEFT):

mt+Rhr7o6HaaEEmKiqTkKKCXDTGsvvS4NOutxb8fxZp4d7jii0mAAAAAElFTkSuQmCC

get_global_mouse_position().x

gWn61HuGOyMZQAAAABJRU5ErkJggg==

get_global_mouse_position().y

8CxOtKbhyu6S8AAAAASUVORK5CYII=

Add an Area2D as a child node of the sprite, and add a CollisionShape2D as a child node of the Area2D.

In the Inspector, choose the correct shape, then in the viewport move and/or resize it to fit the sprite.

Select the Area2D node, then in the Node tab, double-click the input_event signal and choose the sprite.

var draggable = true

var dragging = false

func _on_Area2D_input_event(viewport, event, shape_idx):

if event is InputEventMouseButton and event.pressed and draggable:

dragging = true

func _unhandled_input(event):

if event is InputEventMouseButton and not event.pressed:

dragging = false

if dragging and event is InputEventMouseMotion:

position += event.relative

sxvZgw5RBIUAAAAASUVORK5CYII=

draggable = false

bXhqB6u5PGcL+B1vow9UTpVLGcCMGz64AH8B2XctxQEDsA2AAAAAElFTkSuQmCC

For this to work, you first need to set up the loudness (see the Events section).

loudness

wO2Dt0JpWKjhAAAAABJRU5ErkJggg==

For this to work, you first need to set up the timer (see the Events section).

timer

eRVQ5EkCWvJfTxzbeDRxygefojI5vFSDG89QluDKIZy0aKhUPIPOwuacafifuwAAAAASUVORK5CYII=

For this to work, you first need to set up the timer (see the Events section).

timer = 0

ziSnjMxFIMspU7XIcspULbKcMlXLj81pLXEmgbhFAAAAAElFTkSuQmCC

$"../Sprite".position.x

tkB9OcUjwAAAABJRU5ErkJggg==

OS.get_datetime().year

lsF6ooit7AH2Nf6Oc2kwDE1WBoy3SG8AmxLbwd9qEQUAAAAASUVORK5CYII=

OS.get_unix_time()/86400.0 - 10957

wBrvj4KIyOXowAAAABJRU5ErkJggg==

This only works in Windows. For Linux or MacOS, use OS.get_environment("USER")

OS.get_environment("USERNAME")

Operators

AOYHsRcg8nxBAAAAAElFTkSuQmCC

+

NEw6Y8vkMAAAAAElFTkSuQmCC

-

AbwkslLcaw0kwAAAABJRU5ErkJggg==

*

0XZWUHGZlTzfIAAAAASUVORK5CYII=

/

q9HQmATJYqvRNhEnZj+B6XkwgGb7SN2AAAAAElFTkSuQmCC

First, set up a random generator:

var rng = RandomNumberGenerator.new()

Then this will produce a random number:

randi_range(1, 10)

EgbDCw7LsljeWsbw3EhSETT5dooXGN5wkhJXfwETTKO79U2mvgAAAABJRU5ErkJggg==

> 50

HfpHKAAAAAElFTkSuQmCC

< 50

u+SCkUymAwcncuMPYymqCxSuXSSocgCk0qlMPdwHswUBzbMF7VJzBSHG9GbkvMqG0xRhVMRzGuqfwBz6UsdRbZkmQAAAABJRU5ErkJggg==

== 50

35CKFbCMhYIAAAAASUVORK5CYII=

and

You can also use &&

nW39pAKhBrFy5k8FBfmobiwv9cI5GP6gbLcAAAAAElFTkSuQmCC

or

You can also use ||

h5pbAIIfiofSgVQkh7sP5aPgGKRIgGRnbOegAAAABJRU5ErkJggg==

not

You can also use !

AR5BcaoTgFLUAAAAAElFTkSuQmCC

"apple" + " " + "banana"

+T4AAAAABJRU5ErkJggg==

Godot starts counting from 0 rather than 1. So the first letter is letter [0], the second one is [1], and so on.

"apple"[0]

zIGbMSQsQq6HFEbQZfkCNriH8rZdWhEKSwElSkFcCFVIETmrKIaXqodCfRotehYfzj7C1s5WS52l9m73p38Scex5W5xOMLBpA2em8EmhocQSjywxsGy+w6l07sNdpAcrr+JQH9Jnrf+muLaDhEywiAAAAAElFTkSuQmCC

"apple".length()

0eBB1iQgXz8AAAAASUVORK5CYII=

"a" in "apple"

+N3pHbWzorWvDh3LcoDG8NKDJ+ByswtMGiUebiAAAAAElFTkSuQmCC

%

ln8AifkqlIwsagwAAAAASUVORK5CYII=

round(…)

8AUoXFWuV2LT8AAAAASUVORK5CYII=

abs(…)

Variables

32uzS+OFcYJQIUkIKyQJYeUvkqAm1Jn3OisAAAAASUVORK5CYII=

var

wFBvTuomSytVwAAAABJRU5ErkJggg==

my_variable

bhO5MYfQxP2Ij+5BZrwL6ZLsQ3SkHT66l7SwhKqpyyeZYmtXwV56HoHzv0Jwtl8X9o0nEZqnG37QhOaGfEeM0HQQaQlNxxdWKLqrhTIkBAAAAABJRU5ErkJggg==

my_variable = 0

W2hShuHf7AAAAAElFTkSuQmCC

my_variable += 1

AzLfeG4oQu1AAAAAAElFTkSuQmCC

Add a Label node to the scene, then resize and position it as desired. In func _process for your sprite include this:

$"../Label".text = str(my_variable)

Afj5dUq+AAIMAAAAAElFTkSuQmCC

$"../Label".hide()

PSFJEnBdtyG49q7J6XSCMAwHP4JPPH894Xg8tmYrvQUmESRTIv4A4H2O8g7b184AAAAASUVORK5CYII=

An array (list) can be made by putting values between square bracket, separated by commas. For example:

var my_list = ["apple", "banana", "carrot"]

0a4Si2Y2GGUAAAAASUVORK5CYII=

my_list.push_back("thing")

OAAAAAElFTkSuQmCC

Godot starts counting from 0 rather than 1. So the first item is item 0, the second one is item 1, and so on.

my_list.remove(0)

You can also erase the item from the list without knowing where it is in the list.

my_list.erase("apple")

wEyOchwT13hygAAAABJRU5ErkJggg==

my_list.clear()

wNtg7n7pKiBFAAAAABJRU5ErkJggg==

Godot starts counting from 0 rather than 1. So to insert the item at the start, use 0, to insert after the first item, use 1.

my_list.insert(0, "thing")

g+26thAFiqmuQAAAABJRU5ErkJggg==

Godot starts counting from 0 rather than 1. So to replace the item at the start, use 0, to replace the second item, use 1.

my_list.remove(0)

my_list.insert(0, "thing")

H4qncp7UAAAAASUVORK5CYII=

Godot starts counting from 0 rather than 1. So the first item is item 0, the second one is item 1, and so on.

my_list[0]

AGyTqrstCmOOAAAAAElFTkSuQmCC

The result will be -1 if thing is not in the list.

my_list.find("thing")

fQ959beiGJYEPpcURYGqqpaNVztW+fQfPir3DSqLjE0AAAAASUVORK5CYII=

my_list.size()

O7StZS0bAFvLWv8DfcW3ZEEVSiYAAAAASUVORK5CYII=

my_list.has("thing")

tRTED84DPWfRdcD97IcXUfOvJgNVfOKLhPqQf0HXTVF+POyEBEAAAAASUVORK5CYII=

Add an ItemList to the scene, tick Auto Height, then resize and position as desired. In func _process include this:

$"../ItemList".clear()

for item in my_list:

$"../ItemList".add_item(item)

sCYD7SD8w5BXlsqqV1EUqKpalQRvl7oseXSMOPshwiNdIKOHIA49mhcy2oXwOy8g9tt8VRKz07D0OUDK6t+QN0Fd+8f2BrOM81AnhvgPVdhLgbKu9hsAAAAASUVORK5CYII=

$"../ItemList".hide()

My Blocks

XrUZjGusPwrXMvl8rXegAAAAASUVORK5CYII=

These are called functions in Godot. The brackets are used to choose the parameters (inputs) for the function.

Include an = next to the parameter to set what it will be if no value is given when the function is used. For example:

func my_function(param1, param2=1):

return param1+param2

The above code creates the function. Then to call (run) the function, use its name, for example this would produce 2:

my_function(1)