A
alexfresh
Guest
Hi, I broke my game and can't figure out what I did wrong :/
So my game has entities (animals and plants) that have a lot of common variables to be able to access common scripts.
To define the default values of each species variables I use ds_maps that are set up in a game initialisation script, performed by a persistent control object, that also holds all kinds of ds_maps and other variables.
I use a ds_map for each entity type and had them set up seperately in the past, it looked like this:
// MOSS
moss_map = ds_map_create();
moss_map [? "does_procreate"] = true;
moss_map [? "procreate_cooldown"] = 3;
[...]
// POOP
poop_map = ds_map_create();
poop_map [? "does_procreate"] = false;
poop_map [? "procreate_cooldown"] = 0;
[...]
Everything was fine, but it was a ton of copying, pasting and replacing the map name, whenever I set up a new species, so I decided to use another map for initialisation, so I would just have to replace two lines for each object and then focus on the actual values instead of all that copypasting. Kinda like this:
// MOSS
init_map = ds_map_create();
moss_map = ds_map_create();
init_map [? "does_procreate"] = true;
init_map [? "procreate_cooldown"] = 3;
[...]
moss_map = init_map;
ds_map_destroy(init_map); // I tried this with and without destroying the init_map, same result
// POOP
init_map = ds_map_create();
poop_map = ds_map_create();
init_map [? "does_procreate"] = true;
init_map [? "procreate_cooldown"] = 3;
[...]
poop_map = init_map;
ds_map_destroy(init_map);
Now all entities apparently spawn with the default values for the last entity type I defined in the initialisation script. That's just wrong and I can't get behind it, I mean I made the init_map stored its content in the moss_map, then gave it different values and stored them in another map - how can the moss_map get the values from these other maps?
The script is only triggered once during a game start event, what is happening here?
Btw the game was already super cool before it broke :/
So my game has entities (animals and plants) that have a lot of common variables to be able to access common scripts.
To define the default values of each species variables I use ds_maps that are set up in a game initialisation script, performed by a persistent control object, that also holds all kinds of ds_maps and other variables.
I use a ds_map for each entity type and had them set up seperately in the past, it looked like this:
// MOSS
moss_map = ds_map_create();
moss_map [? "does_procreate"] = true;
moss_map [? "procreate_cooldown"] = 3;
[...]
// POOP
poop_map = ds_map_create();
poop_map [? "does_procreate"] = false;
poop_map [? "procreate_cooldown"] = 0;
[...]
Everything was fine, but it was a ton of copying, pasting and replacing the map name, whenever I set up a new species, so I decided to use another map for initialisation, so I would just have to replace two lines for each object and then focus on the actual values instead of all that copypasting. Kinda like this:
// MOSS
init_map = ds_map_create();
moss_map = ds_map_create();
init_map [? "does_procreate"] = true;
init_map [? "procreate_cooldown"] = 3;
[...]
moss_map = init_map;
ds_map_destroy(init_map); // I tried this with and without destroying the init_map, same result
// POOP
init_map = ds_map_create();
poop_map = ds_map_create();
init_map [? "does_procreate"] = true;
init_map [? "procreate_cooldown"] = 3;
[...]
poop_map = init_map;
ds_map_destroy(init_map);
Now all entities apparently spawn with the default values for the last entity type I defined in the initialisation script. That's just wrong and I can't get behind it, I mean I made the init_map stored its content in the moss_map, then gave it different values and stored them in another map - how can the moss_map get the values from these other maps?
The script is only triggered once during a game start event, what is happening here?
Btw the game was already super cool before it broke :/