• Godot Help
  • GD4 Signal: Can't convert argument [missing argptr, type unknown]

Hello,
I'm recreating a GD4 project from the original GD3 Inventory project. Right now I'm trying to get a tooltip to appear when mouse enters inventory item. Problem is on slot.mouse_entered.connect...

Inventory.gd

const ItemSlotClass = preload("res://Scripts/ItemSlot.gd");

func _ready():
	var slots = get_node("Panel/ScrollContainer/GridContainer");
	for _i in range(MAX_SLOTS):
		var slot = ItemSlotClass.new();
		slot.mouse_entered.connect(self.mouse_enter_slot.bind([slot]));
		#Can't convert argument 1 from [missing argptr, type unknown] to Object

ItemSlot.gd

extends Panel

@export var slotType := Global.SlotType.SLOT_DEFAULT;
var slotIndex;
var item = null;
var style;

func _init():
	mouse_filter = Control.MOUSE_FILTER_PASS;
	custom_minimum_size = Vector2(34, 34);
	style = StyleBoxFlat.new();
	style.set_border_width_all(2);
	set('custom_styles/panel', style);
	
func setItem(newItem):
	add_child(newItem);
	item = newItem;
	item.itemSlot = self;

I don't know what to look for to fix this. What am I missing?

Note: I have Inventory.gd attach to a Control node while the original is attach to a Panel, not sure if it makes a difference.

Thank you.

  • Why are you passing in an Array with one item?

    I'm not familiar with the new syntax, but it looks like you should just bind slot.

Why are you passing in an Array with one item?

I'm not familiar with the new syntax, but it looks like you should just bind slot.

    cybereality

    That just fixes it lol.

    Why are you passing in an Array with one item?

    To be honest I don't fully know what's going on myself. I am stripping Inventory System Example 2.0 to minimum then slowly add each function to try to understand them.

    Here this is when a button is pressed:

    func _on_get_item_pressed():
    	var slot = getFreeSlot();
    	if slot:
    		var item = itemDictionary[randi() % itemDictionary.size()];
    		var itemName = item.itemName;
    		var itemIcon = item.itemIcon;
    		var itemValue = item.itemValue;
    		var slotType = item.slotType;
    		slot.setItem(ItemClass.new(itemName, itemIcon, null, itemValue, slotType));

    My understanding is that one item "slot" is pulling random item with value from itemDictionary everytime the button is pressed. If not then I'm probably wrong or off the mark with your question 😆 pls let me know

    BTW that error "argptr" does it mean "argument parameter"? In this case the error is actually pointing to bind(slot) rather then "self" as I originally thought?

    Yes, bind([slot]) is the function, argptr probably means argument pointer, which is essentially a reference to an Object, slot. I am not familiar with that function, but my guess is that a Callable (basically a function) needs to be bound to the object it is called on, and an Array is not the correct type to call a function.