finepointcgi / Godot-Horror-Game-GD

28 stars 5 forks source link

Error when you try to move or trash an empty slot. #4

Closed RobertSzaszak closed 1 year ago

RobertSzaszak commented 1 year ago

Managed to fix the error by modifying the Drag and Drop Script

func dragAndDrop():
    #Drag and Drop
    $MouseArea.position = get_tree().root.get_mouse_position()
    if hoveredButton != null:
        if Input.is_action_just_pressed("Throw"):
            grabbedButton = hoveredButton
            lastClickedMousePos = get_tree().root.get_mouse_position()
            print(lastClickedMousePos)
        if lastClickedMousePos.distance_to(get_tree().root.get_mouse_position()) > 2:
            if Input.is_action_pressed("Throw") && hoveredButton != null:
                $MouseArea/InventoryButton.show()
                $MouseArea/InventoryButton.UpdateItem(grabbedButton.currentItem, 0)

            if Input.is_action_just_released("Throw"):
                if overTrash && hoveredButton != null:
                    DeleteButton(grabbedButton)
                else:
                    SwapButtons(grabbedButton, hoveredButton)
                    $MouseArea/InventoryButton.hide()
                pass
finepointcgi commented 1 year ago

This issue should be fixed