#get meta of the script

1 messages · Page 1 of 1 (latest)

gaunt latch
#

Hello,
How to get the script metadata and not the object metadata the script is attached to? Thanks

Long story:
A little exercise here, stopped by this.
I'm writing a simple script to be attached to an object. The script has metadaya "destroy": if "destroy" is on, the object is deleted (at the moment it just prints a message). So I've created the script and attached to the object. But when I run the project, this is the error I have:
deleteme.gd:5 @ _ready(): The object does not have any 'meta' values with the key 'destroy'.
The script is this one:
`extends Node

func _ready():
var destroy = self.get_meta("destroy")

if destroy:
    print("nghea")

func _process(delta):
pass`

What am I doing wrong?
The aim was learning Godot in creating a generic script to be attached to any object and see how to reference that object inside the script.
Thanks in advance.

knotty trout
#

What do you mean by script metadata?

gaunt latch
#

Hi @knotty trout ,
I've created a metadata at the script level, not object level.

knotty trout
#

I dont think such a thing exists

gaunt latch
#

In other words, I'm seeing a videotutorial about scripting in Unity and I was wondering if the same could be done in Godot.
The script has this: public <variableType> <variableName>
That publish the variable in the UI of the script.
I thought metadatas in Godot do the same thing.

knotty trout
#

You will need to use the @export annotation for that

#

@export var my_variable: SomeType

gaunt latch
#

oh! now I see!

knotty trout