Thanks Orange, but how do i implement it?
Is my code apart fromcalling the wrong thing correct?
Thanks Orange, but how do i implement it?
Is my code apart fromcalling the wrong thing correct?
So i have been playng screeps for a bit and I notice for maximun efficiency in my code i would need to be able to withdraw from containers and storages. However, Creeps will not, first off, place resources in a storage for one reason or other, and when they do, they will not withdraw; same goes with containers; i cannot withdraw from them. Not only that, my repair screeps refuse to repair storages.
if(creep.memory.repairing) {
var targets = creep.room.find(FIND_STRUCTURES, {
filter: (structure) => {
return (structure.structureType === STRUCTURE_SPAWN ||
structure.structureType === STRUCTURE_ROAD ||
structure.structureType === STRUCTURE_RAMPART ||
structure.structureType === STRUCTURE_EXTENSION ||
structure.structureType === STRUCTURE_CONTAINER ||
structure.structureType === STRUCTURE_STORAGE ||
structure.structureType === STRUCTURE_WALL) && (structure.hits < 5000);
}
});
if(targets.length > 0) {
if(creep.repair(targets[0]) === ERR_NOT_IN_RANGE) {
creep.moveTo(targets[0])
}
}
a code that causes the screeps to attempt to withdraw from a storage but not extentions
/*if (creep.carry.energy < creep.carryCapacity && Game.spawns['Spawn1'].energy < Game.spawns['Spawn1'].energyCapacity){
var exchange = creep.room.find(FIND_STRUCTURES, {
filter: (structure) => {
return (structure.structureType == STRUCTURE_EXTENSION ||
structure.structureType == STRUCTURE_CONTAINER||
structure.structureType == STRUCTURE_STORAGE ||
structure.structureType == STRUCTURE_TOWER) && structure.energy == structure.energyCapacity;}
});
if(exchange.length > 0) {
if(creep.withdraw(exchange[0], RESOURCE_ENERGY, creep.carryCapacity-creep.carry.energy) == ERR_NOT_IN_RANGE) {
creep.moveTo(exchange[0]);
}
}
}*/
And attempt to withdraw from extentions
var resource = Game.spawns.Spawn1||extentions;
if(creep.withdraw(resource, RESOURCE_ENERGY) == ERR_NOT_IN_RANGE) {
creep.moveTo(resource);
}
I would love help, please and thank you