TypeError: require(...).getUniqueName is not a function
at .createCreep (evalmachine.<anonymous>:1:72)
at Object.module.exports.loop (main:45:45)
at __mainLoop:1:52
is what i get with my script that works before i went to bed but after that it wouldn't work so i thought at first not enough energy but nope when i respawned the problem presisted
this is my script (i know pretty basic but it does the job keeping my place running):
main
var roleHarvester = require('role.harvester');
var roleUpgrader = require('role.upgrader');
var roleBuilder = require('role.builder');
module.exports.loop = function () {
for(var name in Game.rooms) {
console.log('Room "'+name+'" has '+Game.rooms[name].energyAvailable+' energy');
}
var tower = Game.getObjectById('136f5028c6fc960974e187ef');
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);
}
}
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);
}
}
for(var name in Memory.creeps) {
if(!Game.creeps[name]) {
delete Memory.creeps[name];
console.log('Clearing non-existing creep memory:', name);
}
}
var harvesters = _.filter(Game.creeps, (creep) => creep.memory.role == 'harvester');
console.log('Harvesters: ' + harvesters.length);
if(harvesters.length < 3) {
var newName = Game.spawns['Spawn1'].createCreep([WORK,CARRY,MOVE], undefined, {role: 'harvester'});
console.log('Spawning new harvester: ' + newName);
}
var upgraders = _.filter(Game.creeps, (creep) => creep.memory.role == 'upgrader');
console.log('Upgraders: ' + upgraders.length);
if(upgraders.length < 0) {
var newName = Game.spawns['Spawn1'].createCreep([WORK,CARRY,MOVE], undefined, {role: 'upgrader'});
console.log('Spawning new upgrader: ' + newName);
}
var builders = _.filter(Game.creeps, (creep) => creep.memory.role == 'builder');
console.log('Builders: ' + builders.length);
if(builders.length < 0) {
var newName = Game.spawns['Spawn1'].createCreep([WORK,CARRY,MOVE], undefined, {role: 'builder'});
console.log('Spawning new builder: ' + newName);
}
}
role.harvester
var roleHarvester = {
/** @param {Creep} creep **/
run: function(creep) {
if(creep.carry.energy < creep.carryCapacity) {
var sources = creep.room.find(FIND_SOURCES);
if(creep.harvest(sources[0]) == ERR_NOT_IN_RANGE) {
creep.moveTo(sources[0]);
}
}
else {
var targets = creep.room.find(FIND_STRUCTURES, {
filter: (structure) => {
return (structure.structureType == STRUCTURE_EXTENSION || structure.structureType == STRUCTURE_SPAWN || structure.structureType == STRUCTURE_TOWER) &&
structure.energy < structure.energyCapacity;
}
});
if(targets.length > 0) {
if(creep.transfer(targets[0], RESOURCE_ENERGY) == ERR_NOT_IN_RANGE) {
creep.moveTo(targets[0]);
}
}
}
}
};
module.exports = roleHarvester;
role.builder
var roleBuilder = {
/** @param {Creep} creep **/
run: function(creep) {
if(creep.memory.building && creep.carry.energy == 0) {
creep.memory.building = false;
creep.say('harvesting');
}
if(!creep.memory.building && creep.carry.energy == creep.carryCapacity) {
creep.memory.building = true;
creep.say('building');
}
if(creep.memory.building) {
var targets = creep.room.find(FIND_CONSTRUCTION_SITES);
if(targets.length) {
if(creep.build(targets[0]) == ERR_NOT_IN_RANGE) {
creep.moveTo(targets[0]);
}
}
}
else {
var sources = creep.room.find(FIND_SOURCES);
if(creep.harvest(sources[0]) == ERR_NOT_IN_RANGE) {
creep.moveTo(sources[0]);
}
}
}
};
module.exports = roleBuilder;
role.upgrader
var roleUpgrader = {
/** @param {Creep} creep **/
run: function(creep) {
if(creep.memory.upgrading && creep.carry.energy == 0) {
creep.memory.upgrading = false;
creep.say('harvesting');
}
if(!creep.memory.upgrading && creep.carry.energy == creep.carryCapacity) {
creep.memory.upgrading = true;
creep.say('upgrading');
}
if(creep.memory.upgrading) {
if(creep.upgradeController(creep.room.controller) == ERR_NOT_IN_RANGE) {
creep.moveTo(creep.room.controller);
}
}
else {
var sources = creep.room.find(FIND_SOURCES);
if(creep.harvest(sources[0]) == ERR_NOT_IN_RANGE) {
creep.moveTo(sources[0]);
}
}
}
};
module.exports = roleUpgrader;
anyone knows what to do?