Created supplier and builder functions

This commit is contained in:
unknown
2023-08-29 20:43:10 +02:00
parent 523a2e0005
commit 112c3c3a97
8 changed files with 239 additions and 30 deletions

View File

@@ -3,6 +3,26 @@ module.exports = {
},
tick(creep){
if(!creep.pos.isNearTo(creep.room.controller)) { creep.moveTo(creep.room.controller); return; }
if(creep.store.getUsedCapacity(RESOURCE_ENERGY) == 0) { getOrWaitForEnergy(creep); return; }
creep.upgradeController(creep.room.controller);
}
}
function getOrWaitForEnergy(creep){
if(!creep.memory.container) scanForContainer(creep);
if(creep.memory.container) getEnergyFromContainer(creep);
}
function getEnergyFromContainer(creep){
const container = Game.getObjectById(creep.memory.container);
if(creep.withdraw(container, RESOURCE_ENERGY) == ERR_NOT_IN_RANGE) creep.moveTo(container);
}
// duplicate see miner
function scanForContainer(creep){
const container = creep.room.controller.pos.findInRange(FIND_STRUCTURES, 1, {
filter:{structureType:STRUCTURE_CONTAINER}
})[0];
if(container) creep.memory.container = container.id;
}