Connecting signals from for loop - completely lost

This is such an overly specific question, I don’t even know where to start.

Godot Version

v4.5.stable.official [876b29033]

Question

not even going to try to summarize this in an all purpose way just go to the context

Context

I am using “rulesets” as I call it. Basically just Super Smash Brothers: Ultimate’s gameplay settings thing. You can modify your run’s settings (changing the time limit, adding a speed boost, etc.), and I want it to where you can save as many as you want and come back to it later to load up a game quickly.
I currently have it to where you can modify the settings and save it to your FileSystem, and I do have an idea on how to load the data (load saved values from file onto a variable, change node data to aforementioned variable. Long but functional).
Okay finally here’s the good part: when you get into the selection screen, I am going to be loading each ruleset as a button. You press it, it changes the node data to what was set, it sends you to the next screen, and the game will reference the node data when it loads in.
So, I believe I need to use a for loop to load in buttons (each with metadata of their settings), and when clicked, it sends you to the next screen. I have no idea how to do this.

Previous Attempts Thought Processes

I never actually tried to do this yet, primarily because I do not know where to start, but I did have some ideas

  1. Using a for loop while connecting each button pressed signal to a variable, then sending that through a function that awaits the signal, before sending you on your way.
    I am not sure if I am able to connect a signal to a variable, though.

I may be able to use an OptionButton to store the ruleset selector, and just have a button that is always active, but I am a little attached to the multi-button idea, so I would prefer to stick to it unless it is virtually impossible.

Code

All I currently have to show is the code to use the option data to create the buttons that I need to connect signals to.
This is just about 1:1, except for some node paths which I shortened for visual convenience.

func button_data(ruleset_data: Array[Dictionary]):
	if ruleset_data:
		get_node("text_thing").visible = false
		for data in ruleset_data:
			var button = Button.new()
			button.name = data["name"]
			button.custom_minimum_size.y = 100.0
			
			var label = Label.new()
			label.horizontal_alignment = HORIZONTAL_ALIGNMENT_CENTER
			label.vertical_alignment = VERTICAL_ALIGNMENT_CENTER
			label.autowrap_mode = TextServer.AUTOWRAP_WORD_SMART
			label.layout_mode = 1 # Anchors - allowing to fill the size of the label to it's container
			label.set_anchors_preset(PRESET_FULL_RECT)
			
			button.add_child(label)
			get_node("button_container").add_child(button)
	else:
		get_node("text_thing").visible = true

Notes

Hi hi hi, I am so sorry how messy it is and that I haven’t actually attempted solving this, I truly do not know where to go D: I hope this isn’t too much of a problem for you. Okay I’m going to try to see if I can connect my SaveData.load_data() thing to my button_data() loader cya

Using a for loop while connecting each button pressed signal to a variable, then sending that through a function that awaits the signal, before sending you on your way.
I am not sure if I am able to connect a signal to a variable, though.

You are on the right track. However, you don’t need to await for a signal - a function connected to the signal will execute when the signal is emitted without you having to keep track of it specifically. (Awaiting for a signal should rather be done in cases where you need to wait for the engine to do something, like processing a frame)

I would do the following (in pseudo-code)

  1. Get all rulesets into an Array
  2. for each ruleset in the Array:
    1. create a button for the ruleset
    2. connect the ruleset’s button pressed signal to a function that will handle loading any ruleset, making sure to bind the ruleset as an argument
  3. make the function that loads the ruleset, which should:
    1. take an argument ruleset, which is a single ruleset array
    2. use the aforementioned ruleset to change the game settings

Also, you usually can’t connect a signal to a variable, since most variables don’t hold data of the Callable type. (Callables are also called functions and methods sometimes)