Transfer energy from spawn to controller
-
let code = creep.transfer(spawnFromThatRoom, RESOURCE_ENERGY, 15) this.logger.log('transfer code', code)
I use this code and transfer returns -6 = not enough energy. But spawn has 300/300 energy. Creep is also at the adjusted square near spawn. What does -6 in this case mean? I can't get energy from spawn?
-
Transfer is the wrong direction, you are looking for creep.withdraw in this case. Although withdrawing energy from the spawn is generally not a recommended strategy.
Transfer resource from the creep to another object. The target has to be at adjacent square to the creep.
Withdraw resources from a structure or tombstone. The target has to be at adjacent square to the creep
-
let creep = _.filter(Game.creeps, function(c){ return c.getActiveBodyparts(WORK) > 0 && c.getActiveBodyparts(CARRY) > 0; })[0]; let spawn = creep.room.find(FIND_MY_SPAWNS)[0]; if(creep.pos.getRangeTo(spawn) == 1 && creep.withdraw(spawn, RESOURCE_ENERGY) == OK) creep.upgradeController(creep.room.controller); else creep.moveTo(spawn);
I think.