#Setting the value of a Metadata Dictionary

14 messages · Page 1 of 1 (latest)

sand isle
#

Hello! I'm still new to Godot and GDScript.
I'm struggling to figure out how to use set_meta() to set one of these values to true. Thanks in advance!

chilly girder
#

Is there a specific reason you're using metadata for this purpose? I haven't really seen it used before and based on the screenshot I'm not sure if this is a good usecase.

sand isle
slow pulsar
#

ahh i see~ might be better to use a variable in the script for it rather than the metadata eg:

@export var test : Dictionary

and then you get the same ui to change the values in the editor but can access it much easier:

  • get: test.get("Bouncy") or test["Bouncy"]
  • set: test["Bouncy"] = true
sand isle
#

alrighty then, thank you!

sand isle
#

acutally one more question. I decided an array is better suited for this. is there a way I can use an enum or something to give each of the numbers a name or no?

cedar raven
# sand isle

Don’t think so, afaik that’s (one) of the main reasons to use a dictionary (it’s also 100x faster)

chilly girder
#

This makes me wonder if a bitmask would be applicable

chilly girder
#

I know they have faster lookup, but not that much insanely faster

#

Actually, arrays seem to sometimes beat out dictionaries at lookup even

#

Being a high level language, the differences between data types are much less of an issue. Focus on using what works.