how do I change the @export parameters during instance?

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By BOX_Milk

hi
I need to make use of the item
and I have in the script of the item there are 2 variables (name, icon)
and I need to change it during spawn,
but I don’t know how to do
it, please help me

:bust_in_silhouette: Reply From: SnapCracklins

just use export in the code and change it in the inspector (right panel by default) in the editor:

export var _itemParam1 = 1
export var _itemParam2 = 2

I need to change the parameters through the code
and not through the inspector

BOX_Milk | 2023-02-25 20:03

:bust_in_silhouette: Reply From: Oian

Have you tried overriding the init virtual method:

func _init():
    export_param1 = value

and if you want to change these parameters from another script, then you need a reference to the item.
Say if you do var item = ITEM.instantiate()
then you can do item.export_param1 = value

and so on.