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;