title: Finding closest creep to a given creep
body: <p>Having significant difficulty finding the closest creep to a creep given that must have a specific set of roles and must not already have a designated partner. </p>
  
  <p>This is for the purpose of setting up dedicated miners and dedicated energy carriers (which must find the closest miner or harvester and carry their energy).</p>
  
  <p>I've tried (where creep variable is the creep running the script):</p>
  
  <pre><code>var nearestMinerCreep = creep.pos.findNearest(Game.MY_CREEPS, {
                  filter: function(creep) {
                      return (creep.memory.role == "miner" 
                      || creep.memory.role == "harvester") 
                      &amp;&amp; !creep.memory.partner;
                  }
              });
  </code></pre>
  
  <p>But findNearest() seems to have been depricated. Replacing this with variations of findClosestByPath() and findClosestByRange() don't work either. The best I've been able to do is get a creep's position with this:</p>
  
  <pre><code>var nearestPos = (creep.pos.findfindClosestByPath(FIND_MY_CREEPS)).pos;
  </code></pre>
  
  <p>But this is unfiltered and not specific enough due to the need to transfer energy. Thanks in advance for any help!</p>