One Godot thing I like is Signals. I've used similar features elsewhere, but the specific way you set these up is interesting! I'm gonna type up an explanation to help solidify it in my head.
So let's say I want something to happen when I click a UI button. This multiplayer tutorial by curtjs has buttons to Host and Join a session. You can see the green UI Nodes in the leftmost column, and the text buttons they draw in the main viewport.

In the Game scene script, I've already added the signal for _on_host_pressed()
. I'm going to create the Signal for when Join is pressed.

(as a note, by default the Inspector and Node columns are on the right side of the screen. I don't like this; it means clicking a Node on the left, and then moving your eyes and cursor all the way to the other side of the screen to change details. Luckily Godot lets you easily move these to a 2nd column on the left side)
So to make a Signal for clicking the Join button (numbered steps below the image):

- Start by clicking the "Join" Button Node in the Scene tree
- Make sure "Node" panel is clicked. This shows all the built-in Signals
- The BaseButton node type has Signals for
button_down
,button_up
,pressed
, andtoggled
. Double-clickpressed()
- This opens a modal, "Connect a Signal to a Method." If you already had the Game Script selected, all the defaults are good. But you can select the Node Script you want to attach the Signal to. You can also customize the name, but it builds a good default!
_on
seems to be a Signal default,_join
is whatever the Node is named, and_pressed
is the name of the Signal event!
Finally, click Connect or press Return.

That's it! The function is inserted into your script. So now anything you add to the _on_join_pressed()
function will happen when the Join button is pressed!
The Node tab shows the places a signal is received! So presumably you can have the Game script do the Join logic, but could also attach the pressed Signal to other UI elements to animate them, etc. Signals are cool for calling code anytime a certain thing happens, and this is a really neat-feeling way to set up and manage these.

You can also click the little green ->]
icon next to the func to see the connection! So the green icon reminds you this is a Signal, and makes it easy to track where it came from.

Cool!