invalid call non existent function

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By devcutter

so i am trying to make an inventory system quite a simple one but for some resons i cant manage to instantiate my slot scene any idea why i can provide additional information if needed.

my problem is that i get non existent function for instance
here is the script part that handle the instantiation

# Create a new slot for each item in the inventory
	var slot_scene = load("res://Scene/UI/Slot.tscn")
	for i in range(inventory_size.x * inventory_size.y):
		var slot = slot_scene.instance()
		slot.name = str(i)
		slot.connect("slot_pressed", self, "_on_slot_pressed")
		inventory_container.add_child(slot)
		inventory_items.append(null)
:bust_in_silhouette: Reply From: jgodfrey

For Godot 4, I assume you want slot_scene.instantiate()?

i did try instantiate() it now returns i think its because i get string from the self tag
i am a little bit lost on how to convert it basicly and wich type it needs

 @ _ready(): Cannot connect to 'slot_pressed': the provided callable is null.
  <Erreur C++>   Condition "p_callable.is_null()" is true. Returning: ERR_INVALID_PARAMETER

devcutter | 2023-04-04 22:08

You seem to be using Godot 4, but with code that’s meant to be used with Godot 3.x. The signal connection mechanism has been updated in Godot 4 and has a different syntax…

Docs here:

Signal — Godot Engine (4.0) documentation in English

jgodfrey | 2023-04-04 22:15

thanks alot got it finally working heres the updated version this removed all errors and linked my signals properly

var slots = get_node("SlotsContainer/Slots");
	for _i in range(MAX_SLOTS):
		var slot = ItemSlotClass.new();
		slot.mouse_entered.connect(mouse_enter_slot.bind(slot));	
		slot.mouse_exited.connect(mouse_exit_slot.bind(slot));
		slot.gui_input.connect(slot_gui_input.bind(slot));
		slotList.append(slot);
		slots.add_child(slot);

devcutter | 2023-04-05 03:01