Hi. I'm wondering if it's possible to have dynamic names for dictionaries. I'm setting up several dictionaries and I need to be able to call the appropriate one on the fly.
for example, I have a logic block setup to spawn different types of mobs at different times. Each mob is distinguished by their ID number.
This is how I have my dictionaries setup now:
var mobdata1 = { # mob TYPE 1
mesh: preload("res://Scenes/Mobs/MobType_1.tscn")
health
shield
etc...
etc... and so on with the data
}
var mobdata2 = { # mob TYPE 2
mesh: preload("res://Scenes/Mobs/MobType_2.tscn")
health
shield
etc...
etc... and so on with the data
}
I need to be able to call these different dictionaries by referencing their type.
Instead of doing it the way I am now, which is fine while my project stays small.
Here's how I'm setup right now:
if mob.type == 1 then:
use dictionary mobdata1
if mob.type == 2 then:
use dictionary mobdata2
But as my project gets larger I don't want to have to call these checks every time I need to access a stat from my enemy's class.
My question is, is there a means to reference a dictionary dynamically like an array?
This is close to what I need to do, but it won't work.
var mobdata[id] = { # mob TYPE 1
mesh: preload("res://Scenes/Mobs/MobType_1.tscn") }