Navigation

    forum

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

    MKenyon2

    @MKenyon2

    1
    Posts
    670
    Profile views
    0
    Followers
    0
    Following
    Joined Last Online

    MKenyon2 Follow

    Posts made by MKenyon2

    • Trying to for each towers

      I'm trying to write a `for each` for my towers.

      var towers = Game.rooms[roomName].find(FIND_MY_STRUCTURES, {filter: {structureType: STRUCTURE_TOWER}});
      console.log(towers.length); // Gives me 2, correct
      for (var tower in towers) {

          console.log(tower); // Gives me 0 then 1
          console.log('Pos: ' + tower.pos); // Gives me `Pos: undefined`

      }

      I wanted to put this in the for loop:

      var closestDamagedStructure = tower.pos.findClosestByRange(FIND_STRUCTURES, {
      filter: (structure) => structure.hits < structure.hitsMax
      });

      But since tower.pos is undefined, that fails.

      posted in Help
      MKenyon2