role.repairer not defined
-
I tried to put the repairer in my main code but it just said role.repairer when I put it in. Is there anything wrong with my code?
var roleHarvester = require('role.harvester');
var roleUpgrader = require('role.upgrader');
var roleBuilder = require('role.builder');
var roleCleaner = require('role.cleaner');
var roleRepairer = require('role.repairer');module.exports.loop = function () {
for(var name in Memory.creeps) {
if(!Game.creeps[name]) {
delete Memory.creeps[name];
console.log('Clearing non-existing creep memory:', name);
}
}
var tower = Game.getObjectById('e28ad5d0e890c3738c26301b');
if(tower) {
var closestDamagedStructure = tower.pos.findClosestByRange(FIND_STRUCTURES, {
filter: (structure) => structure.hits < structure.hitsMax
});
if(closestDamagedStructure) {
tower.repair(closestDamagedStructure);
}var closestHostile = tower.pos.findClosestByRange(FIND_HOSTILE_CREEPS);
if(closestHostile) {
tower.attack(closestHostile);
}
}
var harvesters = _.filter(Game.creeps, (creep) => creep.memory.role == 'harvester');
console.log('Harvesters: ' + harvesters.length);
var upgraders = _.filter(Game.creeps, (creep) => creep.memory.role == 'upgrader');
console.log('Upgraders: ' + upgraders.length);
var builders = _.filter(Game.creeps, (creep) => creep.memory.role == 'builder');
console.log('Builders: ' + builders.length);
var cleaners = _.filter(Game.creeps, (creep) => creep.memory.role == 'cleaner');
console.log('Cleaners: ' + cleaners.length);if(harvesters.length < 3) {
var newName = Game.spawns['Spawn1'].createCreep( [WORK,WORK,CARRY,MOVE], undefined, {role: 'harvester'});
}
else if(upgraders.length < 3) {
var newName = Game.spawns['Spawn1'].createCreep( [WORK,WORK,CARRY,MOVE], undefined, {role: 'upgrader', upgrading: 'not'});
}
else if(cleaners.length < 4) {
var newName = Game.spawns['Spawn1'].createCreep( [WORK,WORK,CARRY,MOVE], undefined, {role: 'cleaner'});
}
else if(builders.length < 1) {
var newName = Game.spawns['Spawn1'].createCreep( [WORK,WORK,CARRY,MOVE], undefined, {role: 'builder', building: 'not'});
}
for(var name in Game.creeps) {
var creep = Game.creeps[name];
if(creep.memory.role == 'harvester') {
roleHarvester.run(creep);
}
if(creep.memory.role == 'upgrader') {
roleUpgrader.run(creep);
}
if(creep.memory.role == 'builder') {
roleBuilder.run(creep);
}
if(creep.memory.role == 'cleaner') {
roleCleaner.run(creep);
}
if(creep.memory.role == 'repairer') {
roleRepairer.run(creep);
}
}
}
-
Oh, I found the problem. Sorry.