I actually moved it into my spawn check, and It is only called immediately before I try spawning any new creeps. This reduces it's checks and fixed the problem. Good suggestion though @Amadox
Posts made by Iziak
-
RE: Why does role not get loaded onto creep's memory
-
RE: Why does role not get loaded onto creep's memory
You nailed it, still had the leftover dead creep memory clean from the tutorial and was wiping during my creep spawn. Set to check if creep spawner was spawning before doing the memory wipe - all good thank you! I will check out the Channel, much appreciated.
-
Why does role not get loaded onto creep's memory
Can anyone tell me when why this code is able to spawn a creep but does not have its role saved in memory?
var maintainCreeps = function(){
var minHarvesters = 1;
var minBuilders = 3;
var minUpgraders = 2;
var creepWorkerBody = [WORK,WORK,CARRY,CARRY,MOVE,MOVE];
var harvesters = _.filter(Game.creeps, (creep) => creep.memory.role == 'harvester');
console.log('Harvesters: ' + harvesters.length);
if(harvesters.length < minHarvesters) {
Game.spawns.Spawn1.createCreep(creepWorkerBody, 'Harvester'+(harvesters.length+1).toString(), {role: 'harvester'});
}
var upgraders = _.filter(Game.creeps, (creep) => creep.memory.role == 'upgrader');
console.log('Upgraders: ' + upgraders.length);
if(upgraders.length < minUpgraders) {
Game.spawns.Spawn1.createCreep(creepWorkerBody, 'Upgrader'+(upgraders.length+1).toString(), {role: 'upgrader'});
}
var builders = _.filter(Game.creeps, (creep) => creep.memory.role == 'builder');
console.log('Builders: ' + builders.length);
if(builders.length < minBuilders) {
Game.spawns.Spawn1.createCreep(creepWorkerBody, 'Builder'+(builders.length+1).toString(), {role: 'builder'});
}
}
module.exports = maintainCreeps;