Advertisement
Eeems

Untitled

Dec 21st, 2017
139
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. // mining spots defined and stored in memory as =>      miners = ['5a3ae7deca2d336eb2969ea5',...]
  2. // string is the ID of STRUCTURE_CONTAINER
  3. let miners = this.memory.miners;
  4. // get all "miner" creeps
  5. let miningCreeps = _.filter(Game.creeps, (c) => c.memory.role === 'miner');
  6. // populate busyMiners with ID of their assigned STRUCTURE_CONTAINER
  7. // array for mining spots that are busy (have "miner" creep on them)
  8. let busyMiners = _.map(miningCreeps, (c) => c.memory.job.id);
  9. // get ids of not busy miners (get all "miners" not in "busyMiners")
  10. let ids = _.difference(miners, busyMiners);
  11. // select random target from collection "ids"
  12. let object = Game.getObjectById(_.sample(ids));
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement