mirror of
https://github.com/paradizelost/screeps.git
synced 2024-11-25 02:14:44 -06:00
24 lines
790 B
JavaScript
24 lines
790 B
JavaScript
var roleMiner = {
|
|
|
|
/** @param {Creep} creep **/
|
|
run: function(creep,mysource) {
|
|
var sources = creep.room.find(FIND_SOURCES);
|
|
if(creep.harvest(sources[0]) == ERR_NOT_IN_RANGE) {
|
|
creep.moveTo(sources[0]);
|
|
}
|
|
},
|
|
spawn: function(){
|
|
var myrole='miner';
|
|
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 = roleMiner; |