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")
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)
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.