make builder build, not transfer
This commit is contained in:
parent
a629713ed5
commit
3b4cd13dad
6
main.js
6
main.js
@ -5,17 +5,17 @@ var roleBuilder = require('role.builder');
|
||||
var creepRolePriority = ['harvester', 'builder', 'upgrader'];
|
||||
var creepsConfig = {
|
||||
harvester: {
|
||||
bodyParts: [WORK, CARRY, MOVE],
|
||||
bodyParts: [WORK, CARRY, MOVE, MOVE],
|
||||
minimumCreeps: 2,
|
||||
role: roleHarvester
|
||||
},
|
||||
builder: {
|
||||
bodyParts: [WORK, CARRY, MOVE],
|
||||
bodyParts: [WORK, CARRY, MOVE, MOVE],
|
||||
minimumCreeps: 2,
|
||||
role: roleBuilder
|
||||
},
|
||||
upgrader: {
|
||||
bodyParts: [WORK, CARRY, MOVE],
|
||||
bodyParts: [WORK, CARRY, MOVE, MOVE],
|
||||
minimumCreeps: 2,
|
||||
role: roleUpgrader
|
||||
}
|
||||
|
@ -10,16 +10,14 @@ var roleBuilder = {
|
||||
creep.memory.building = true;
|
||||
}
|
||||
if (creep.memory.building){
|
||||
console.log("\tis building");
|
||||
console.log("\t is building");
|
||||
var targets = creep.room.find(FIND_CONSTRUCTION_SITES);
|
||||
|
||||
let transerErrorCode = creep.transfer(targets[0], RESOURCE_ENERGY);
|
||||
if(transerErrorCode == ERR_NOT_IN_RANGE) {
|
||||
var transferErrorCode = creep.build(targets[0]);
|
||||
if(transferErrorCode == ERR_NOT_IN_RANGE) {
|
||||
console.log("\t moving to", targets[0]);
|
||||
creep.moveTo(targets[0]);
|
||||
} else if (transerErrorCode == ERR_INVALID_TARGET){
|
||||
console.log("\tError, invalid Target");
|
||||
}
|
||||
|
||||
} else {
|
||||
console.log("\t","isFindingSources");
|
||||
var sources = creep.room.find(FIND_SOURCES);
|
||||
@ -27,6 +25,8 @@ var roleBuilder = {
|
||||
creep.moveTo(sources[0]);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
};
|
||||
module.exports = roleBuilder;
|
||||
|
Loading…
Reference in New Issue
Block a user