mirror of
https://github.com/paradizelost/screeps.git
synced 2024-11-25 02:14:44 -06:00
22 lines
769 B
JavaScript
22 lines
769 B
JavaScript
|
var roleMiner2 = {
|
||
|
|
||
|
/** @param {Creep} creep **/
|
||
|
run: function(creep) {
|
||
|
var sources = creep.room.find(FIND_SOURCES);
|
||
|
if(creep.harvest(sources[1]) == ERR_NOT_IN_RANGE) {
|
||
|
creep.moveTo(sources[1]);
|
||
|
}
|
||
|
},
|
||
|
spawn: function(){
|
||
|
var myrole='miner2';
|
||
|
var nummyrole=1;
|
||
|
var myroles = _.filter(Game.creeps, (creep) => creep.memory.role == myrole);
|
||
|
if(myroles.length < nummyrole) {
|
||
|
console.log('Miners: ' + myroles.length + ' Needed: ' + nummyrole);
|
||
|
var newName = Game.spawns['Spawn1'].createCreep([WORK,WORK,WORK,WORK,WORK,MOVE], undefined, {role: myrole});
|
||
|
console.log('Spawning new ' + myrole + ': ' + newName);
|
||
|
}
|
||
|
}
|
||
|
};
|
||
|
|
||
|
module.exports = roleMiner2;
|