hey all! I have a question that's killing me for 24 hours. Please help!
In my code I define an enum on a custom Resource:
extends Resource
class_name Currency
enum {
HP = 0,
CREDITS = 1,
GUNS = 2,
NINJAS = 3,
HACKS = 4
}
# game-data.gd
extends Node
var atoms: Dictionary = {
"Currencies": {
Currency.HP: preload("res://data/currencies/hp.tres"),
Currency.CREDITS: preload("res://data/currencies/credits.tres"),
Currency.GUNS: preload("res://data/currencies/guns.tres"),
Currency.NINJAS: preload("res://data/currencies/ninjas.tres"),
Currency.HACKS: preload("res://data/currencies/hacks.tres")
}
}
func _ready():
print(var2str(atoms.Currencies)
# Output:
{
0: Resource( "res://data/currencies/hp.tres"),
3: Resource( "res://data/currencies/credits.tres"),
4: Resource( "res://data/currencies/guns.tres"),
5: Resource( "res://data/currencies/ninjas.tres"),
6: Resource( "res://data/currencies/hacks.tres")
}```
Notice how the keys in my Dict skip integers 1 and 2? Why does it go 0, 3, 4, 5, 6??? Checking on the enum, when I print their values (right after I print the above Dict): Currency.HP =0, Currency.CREDITS = 1. How come it seems to skip 2 numbers when I use it as keys in my Dict? Any ideas??