Navigation

    forum

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

    Kap

    @Kap

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

    Kap Follow

    Posts made by Kap

    • RE: Troubling getting ID of a structure.

      Cheers for that!

      posted in Help
      Kap
    • Troubling getting ID of a structure.

      Hey, having trouble with the code below. It's the -> container.id that's always undefined.

                  for (let source of sources) {
                      let containers = source.pos.findInRange(FIND_STRUCTURES, 1, {
                          filter: s => s.structureType == STRUCTURE_CONTAINER
                      });
      
                      for (let container in containers) {
                          if (_.some(creepsInRoom, b => (b.memory.containerId == container.id && b.memory.role == 'lorry'))) {
                              continue;
                          } else {
                              name = this.createLorry(30, container.id);
                              break;
                          }
                      }
                  }
      

      This code below does almost the same, but here the container.id is never undefined.

              for (let source of sources) {
                  let containers = source.pos.findInRange(FIND_STRUCTURES, 1, {
                      filter: s => s.structureType == STRUCTURE_CONTAINER
                  });
      
                  for (let container of containers) {
                      if (_.some(creepsInRoom, c => c.memory.containerId == container.id && c.memory.role == 'miner')) {
                          continue;
                      } else {
                          name = this.createMiner(source.id, container.id);
                          break;
                      }
                      
                  }
              }
      

      Hope someone can help me out, thanks!

      posted in Help
      Kap