Passing Data with Signals in Godot 4 (custom signals)
all you gotta do is:
1. [NAME OF SIGNAL HERE].emit(PUT_THE_DATA_IN_HERE)
and when you conect, you just gotta do
2. [NAME OF SIGNAL HERE].connect(nameOfFunction) and then define that function:
3.
func [nameOfFunction]( DATA_VAR_NAME ):
define function here
and then
you just do:
4. print( DATA_VAR_NAME ) and you get that data :)
Timeline:
0:00 - Intro
0:27 - Scene setup
0:50 - button pressed signal (NOT CUSTOM SIGNALS YET)
1:53 - using signals + `data`
3:08 - CUSTOM SIGNAL WITH ARGUMENTS/DATA
3:53 - CONNECTING CUSTOM SIGNALS WITH DATA
5:00 - THE IMPORTANT PART - ACC USING THE DATA
5:26 - Showing the importance of order of signals & data
8:00 - Making a level selection screen (WORKED EXAMPLE)
9:21 - Connecting multiple signals (the easy way)
10:24 - Custom classes & Signals