@export Array of 2 Datatypes

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

Hiy, is something like:
@export var array: Array[(String, Int)] = [("test", 5), ("a", 2)] possible with godot?

Longer Question:
I have a resource and want to export it, with a dynamically changeable int.

More Concrete:
I have effects for weapons (like damage something) and I want to be able to specify how much damage the item does. Because the item could also have effects like add armor and stuff like that I would like to store all effects & how much they scale in a Array and export it.


Bad Solutions:

  1. One could use 2 array and always fill them up that they mach each
    other. (Bad because error prone and hard to read)
  2. A Dictionary could be used one value is the Key (e.g. the resource
    effect) & the value is the scale. (Bad because Dict are untyped,
    malformed data could slip in)

If any one knows a better solution, I would really appreciate it!

:bust_in_silhouette: Reply From: spaceyjase

Custom resources.

Create a Weapon resource that exports a string and int. In use, export the Array of type Resource (or the class_name).