Thanks for that clear and short answer Have a god day Sir Yoshi I think all will be ok with your help.
NotGael
@NotGael
2
Posts
551
Profile views
0
Followers
0
Following
Posts made by NotGael
-
RE: Can't find a way to check if a memory attribute exist or not before accessing it.
-
Can't find a way to check if a memory attribute exist or not before accessing it.
I get the number of harvester in each of my room with the code :
let creepsInRoom = spawn.room.find(FIND_CREEPS); .... var numberOfHarvesters = _.sum(creepsInRoom, (c) => c.memory.role == 'harvester');
But each time an enemy come to one of my room and doesn't have a creep.memory.role attribute, I got a NPE. I can't find a way to check if an attribute exist in memory before trying to access it.
(I'm a JS newbie)