How to Check if Spots to a Resource are Full



  • I am new to the game, and I want to find a way to tell my creeps to go to a different energy deposit when the spaces to one are all filled up. Is there a method or a way to do this automatically, or will I have to use flags or something to control them?



  • You need to create a list of sources in Memory and add a free spot counter there. Usually the source ID is stored in creep.memory and creeps only harvest resources from it.

    Perhaps it will also help you:

    const target = creep.pos.findClosestByRange(FIND_SOURCES_ACTIVE);
    
    const count = source.pos.findInRange(FIND_CREEPS, 1).length;