Picking up non energy drops from invaders



  • So i get attacked by invaders which have upgrades. When they die they drop mineral compounds such as HO or UH or whatever they are. My attackers have a single carry slot to pick these up. I'm wondering what code I need to write to have them pick this stuff up before it dissapears (since it only appears for like 10 ticks).

     

    var droppedResource = creep.pos.findInRange(FIND_DROPPED_RESOURCES, 1, {filter: {resourceType: RESOURCES_ALL.filter(function(x) { return x !== RESOURCE_ENERGY; })}})[0];
    if(droppedResource)
    creep.pickup(droppedResource);

     

    This is what I have, but it doesn't appear to work - can anyone help?


  • Culture

    Change your filter to something like this: 

    filter: (x) => { return x.resourceType !== RESOURCE_ENERGY; }



  • ty that worked