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