Using set for exported variable to modify another exported variable

Godot Version

4.3

Question

I have a resource that looks something like this:

extends Resource
class_name LootTableItem

@export var item: Resource
@export var weight: int

is there a way for me to set the weight property through the item’s setter based on a condition of the item? I’ve tried this:

@export var item: Resource:
    set(value):
        if value.get("rarity"):
            weight = value.rarity

but this doesn’t work.
Is there any way to achieve this?

If what you want is that the inspector is updated when changing the item then you’ll need to make the script a @tool script and call Object.notify_property_list_changed() after changing the value to trigger an update in the inspector.