How do I connect a signal from one resource to another resource, and how would the parameters work? Edited*

Godot Version

Gotdot-4

Question

Thank you for reading this message, I have a problem. I need to connect a signal with resource source to another script with resource source, I have tried some methods but they don’t work, I would appreciate your answer for a solution.

extends InventoryData
class_name InventoryDataEquip

var inventory_data: InventoryData

signal use_function_equipment(inventory_data_equip: InventoryDataEquip)

func position_to_conection() -> void:
	inventory_data.inventory_interect.connect(drop_slot_date)

func drop_slot_date(grabbed_slot_data, index: int) -> Slotdate:
	
	if not grabbed_slot_data.itemdata is ItemDataEquip:
		return grabbed_slot_data
	
	if grabbed_slot_data.itemdata is ItemDataEquip:
		use_function_equipment.emit(self)
	
	return super.drop_slot_date(grabbed_slot_data, index)

Connection place

func place_to_conection(inventory_data_equip: InventoryDataEquip) -> void:
	inventory_data_equip.use_function_equipment.connect(to_connect_function)

func to_connect_function(inventory_data_equip: InventoryDataEquip, index):
	use_slot_data(index)

func use_slot_data(index):
	var slot_data = slot_datas[index]

	if slot_data.itemdata is ItemDataEquip:
		slot_data.quantity -= 1
		print("slot data")

You have 2 parameters in the function you want to connect to and only 1 in the signal.

Already, I did it but it still didn’t work, but thanks for your reply, I appreciate your help.

extends InventoryData
class_name InventoryDataEquip

signal use_function_equipment(inventory_data_equip: InventoryDataEquip)

func drop_slot_date(grabbed_slot_data, index: int) -> Slotdate:
	
	
	if not grabbed_slot_data.itemdata is ItemDataEquip:
		return grabbed_slot_data
	
	if grabbed_slot_data.itemdata is ItemDataEquip:
		use_function_equipment.emit(self)
	
	return super.drop_slot_date(grabbed_slot_data, index)

Connection place

func place_to_conection(inventory_data_equip: InventoryDataEquip) -> void:
	inventory_data_equip.use_function_equipment.connect(use_slot_data_equip)

func use_slot_data_equip():
	var slot_data = slot_datas
	
	if not slot_data:
		return

	if slot_data.itemdata is ItemDataEquip:
		slot_data.quantity -= 1
		print("desde use slot data")
	
	print(slot_data.itemdata.name)
	PlayerManager.use_slot_data(slot_data)
	
	inventory_updated.emit(self)

Edited*

signal use_function_equipment(inventory_data_equip: InventoryDataEquip)

1 parameter named inventory_data_equip

inventory_data_equip.use_function_equipment.connect(use_slot_data_equip)
func use_slot_data_equip():

0 parameter in connected function.

The connected function must have the exact same number of parameters as the signal.

func use_slot_data_equip(inventory_data_equip: InventoryDataEquip):
	var slot_data = slot_datas
	
	if not slot_data:
		return

	if slot_data.itemdata is ItemDataEquip:
		slot_data.quantity -= 1
		print("desde use slot data")
	
	print(slot_data.itemdata.name)
	PlayerManager.use_slot_data(slot_data)
	
	inventory_updated.emit(self)

Like this? I did it like you told me this way but it doesn’t work, I really don’t understand why this is happening.

The next thing to do is check if the program is getting to the connected function.
You can use a breakpoint but I usually use a print statement (and print out what the parameter is).

If the program gets there then the next check is the first if statement.
(I don’t know what slot_datas is because it isn’t anywhere in code you are showing. )

If slot_data is null then the program will just return and not do anything.

Do those two checks and see what is happening.

Thanks, I have already checked everything, and I see that the only problem is the signal, it is emitted but still cannot connect.

I don’t know if there is a way to connect these signals to the nodes, the problem is that these are resources, but I can’t find that way.