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.