For my game, my item management system needs for the item’s script to change the player’s last_item variable to the object of the item, but I’m not sure how to get the item script to reference the object that it is attached to (the item).
Oh go figure, I spend all day yesterday and today trying to find something for this but as soon as I post, I figured it out! For anyone who came across this in a google search and needs help, you can get the node path using get_path(), and the Object using get_node(get_path()).
What are you trying to do with the script? It is inheritly referenced, for example self.position = Vector2.ZERO is the same as position = Vector2.ZERO.
Well this would be a long post if I explained ALL the context, but basically the script for the item would set the last_item variable in the player script to the object of the item.
Basically, in the item script: player.last_item = get_node(get_path)). Or, as you have suggested, player.last_item = self.