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