I have an understanding that the action_t.gd is just a script and not a node, so it doesn't have a node path, but I'm just wondering if there's a way to get the node that instantiated the class script.
Node2D, so when you create it with
action_t.new(), it's essentially creating a new node, but not adding it to the tree. When a node is not needed anymore, it should be freed, otherwise it will stay on the memory indefinitely.
action_t is a node, you could add it to the tree and it would be very easy to get the node that created it. You can add it as child of the testbox with
add_child(). Then you can use
get_parent() to get the reference.
@onready var action = action_t.new() # loading reusable code
add_child(action) # adds 'action' as child
func carry(player : Node2D):
var testbox = get_parent() # gets reference to the testbox
testbox.queue_free() # frees testbox and its children with it
Since actiont is a child of testbox, freeing testbox will also free actiont.