Godot Version
4.4.1
Question
Hi, I’m new to Godot and relatively new to coding in general, currently working on a drag and drop game.
In my _drop_data function I am trying to do two things:
- Check that the data being dropped is the appropriate item type
- Prevent the data being dropped if an item has already been dropped there
I’m running into an issue with #2. The rest of the code seems to be working as intended, but I can’t work out how to get the first elif statement working, aka get the console to print feedback when the droppable area is not empty. There are no debugger errors and It doesn’t appear to be dropping any data, but the console isn’t printing the relevant text either. I’ve hit a bit of a wall so any advice is appreciated. Apologies if I haven’t included enough info in the post.
@export_enum("HOTDOG:0",
"BURGER:1",
"TOMATOSAUCE:2",
"MUSTARD:3",
"LONGBUN:4",
"SHORTBUN:5") var slot_type : int
func _can_drop_data(_pos, data):
return data is Control
func _drop_data(pos, data): #original parent is defined in case it needs to be removed
var dragged_control = data
var current_parent = dragged_control.get_parent()
var current_child = get_child(0)
if dragged_control.slot_type == 0 && current_child == null:
add_child(dragged_control)
elif dragged_control.slot_type == 0 && current_child != null:
print("There is already an ingredient cooking")
elif dragged_control.slot_type != 0:
print("This ingredient is not suitable for grilling")