To explain further and show you the code:
I have scene A with this code (there is a lot more, but this I think is relevant):
var clone
func kloon_maken(): #function to create the instance
clone = v_a_scene.instance()
func kloon_v_a_toevoegen(): #function to add an instance to the tree
node_to_spawn_at.add_child(clone)
clone.rect_min_size = Vector2(600,180)
# Connect the signals from the newly instanced scene to the correct functions:
clone.connect("plus_ingedrukt", self, "plus_ingedrukt_ontvangen"); #connects button 1
clone.connect("minus_ingedrukt", self, "minus_ingedrukt_ontvangen"); #connects button 2
clone.connect("edit_ingedrukt", self, "edit_ingedrukt_ontvangen"); #connects button 3
func plus_ingedrukt_ontvangen(): #do this if button 1 is pressed
Some functions
func minus_ingedrukt_ontvangen(): #do this if button 2 is pressed
some functions
func edit_ingedrukt_ontvangen(): #do this if button 3is pressed
some functions and print("edit pressed")
I have scene B with this code:
signal minus_ingedrukt
signal plus_ingedrukt
signal edit_ingedrukt
func _ready():
# Connect the signals here!
# This will make it where when the buttons are pressed, the correct function is called.
get_node("VBoxContainer/HBoxContainer2/HBoxContainer_plus/TextureButton_plus").connect("pressed", self, "_on_TextureButton_plus_pressed"); #connect button 1
get_node("VBoxContainer/HBoxContainer2/HBoxContainer_minus/TextureButton_minus").connect("pressed", self, "_on_TextureButton_minus_pressed"); #connect button 2
get_node("VBoxContainer/HBoxContainer2/HBoxContainer_edit/TextureButton_edit").connect("pressed", self, "_on_TextureButton_edit_pressed"); #connect button 3
func _on_TextureButton_plus_pressed():
# When the button is pressed, emit the signal from button 1!
emit_signal("plus_ingedrukt")
func on_TextureButton_edit_pressed():
# When the button is pressed, emit the signal from button 2!
emit_signal("edit_ingedrukt")
func _on_TextureButton_minus_pressed():
# When the button is pressed, emit the signal from button 3!
emit_signal("minus_ingedrukt")
Yet if I click on button 3 of a previously created instance, I get an error that the _on_TextureButton_edit_pressed method is not found. So I need a way to tell Godot witch instance it is I am clicking on.