"I have come for your babies"
Lisp
@Lisp
2
Posts
1238
Profile views
0
Followers
0
Following
Posts made by Lisp
-
RE: Shard 3 accessible from other shards.
-
RE: Harvesting energy from an unclaimed room
Ngl it's very hard to read with that formatting.
To post code, surround all the code with 3 backticks (``` code ``')Here it is formatted better
var roleouterharvester = { run: function(creep) { if(creep.carry.energy < creep.carryCapacity) { creep.moveTo(new RoomPosition(4, 13, 'W58S46')); { var sources = creep.room.find(FIND_SOURCES); if(creep.harvest(sources[0]) == ERR_NOT_IN_RANGE) { creep.moveTo(sources[0], {visualizePathStyle: {stroke: '#ffaa00'}}); } } } Else { {creep.moveTo(new RoomPosition(48, 15, ' W59S46')); { var targets = creep.pos.findClosestByRange (FIND_STRUCTURES, { filter: (structure) => { return (structure.structureType == STRUCTURE_EXTENSION) && structure.energy < structure.energyCapacity; } } }); if(targets.length > 0) { if(creep.transfer(targets[0], RESOURCE_ENERGY) == ERR_NOT_IN_RANGE) { creep.moveTo(targets[0], {visualizePathStyle: {stroke: '#ffffff'}}); } } } } }; module.exports = roleouterharvester;
Potentially a fixed version?
var roleouterharvester = { run: function(creep) { if (creep.carry.energy < creep.carryCapacity) { creep.moveTo(new RoomPosition(4, 13, 'W58S46')); if (creep.room.name == 'W58S46') { var sources = creep.room.find(FIND_SOURCES); if (creep.harvest(sources[0]) == ERR_NOT_IN_RANGE) { creep.moveTo(sources[0], {visualizePathStyle: {stroke: '#ffaa00'}}); } } } else { creep.moveTo(new RoomPosition(48, 15, ' W59S46')); var targets = creep.pos.findClosestByRange (FIND_STRUCTURES, { filter: (structure) => { return (structure.structureType == STRUCTURE_EXTENSION && structure.energy < structure.energyCapacity); } }); if(targets.length > 0) { if(creep.transfer(targets[0], RESOURCE_ENERGY) == ERR_NOT_IN_RANGE) { creep.moveTo(targets[0], {visualizePathStyle: {stroke: '#ffffff'}}); } } } } }; module.exports = roleouterharvester;