Navigation

    forum

    • Login
    • Search
    • Categories
    • Recent
    • Popular
    • Users
    • Groups
    1. Home
    2. NotGael
    • Flag Profile
    • block_user
    • Profile
    • Following
    • Followers
    • Topics
    • Posts
    • Groups
    • Blog

    NotGael

    @NotGael

    2
    Posts
    665
    Profile views
    0
    Followers
    0
    Following
    Joined Last Online

    NotGael Follow

    Posts made by NotGael

    • RE: Can't find a way to check if a memory attribute exist or not before accessing it.

      Thanks for that clear and short answer 😉 Have a god day Sir Yoshi I think all will be ok with your help.

      posted in Help
      NotGael
    • 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)

      posted in Help
      NotGael