Question about Room.lookForAtArea call



  • I am trying to find all structures on a given area with the said function.
    Function works fine for terrain etc., but it fails to return more than one structure per tile. I am not sure that it's supposed to return more than one, but the {...} in the docs game this impression.

    Function fails to return the rampart that has an extension built on it.

    function findStructures(spawn){

    var area = spawn.room.lookForAtArea('structure', spawn.pos.y - 1, spawn.pos.x - 1, spawn.pos.y + 1, spawn.pos.x + 1);
    
    var ramparts = [];
    var roads = [];
    var blocked = [];
    
    _.each(area, function(col, y){
        _.each(col, function(cell, x){
         do{  
             //console.log("pos "+ x + " "+ y + " " + cell.length, cell);
             var c = cell.length ? cell.shift() : cell;
    
             if (c.structureType == STRUCTURE_RAMPART){
                 ramparts.push(""+ x + "_" + y);
             }else if (c.structureType == STRUCTURE_ROAD){
                 roads.push(""+ x + "_" + y);
             }else{
                 blocked.push(""+ x + "_" + y);
             }
         }while(cell.length);
     });
    });
    
    //console.log("ramparts 1st"+ found[0]);
    spawn.room.memory.ramparts = ramparts;
    spawn.room.memory.roads = roads;
    spawn.room.memory.blocked = blocked;
    

    }



  • lookForAtArea is definetely broken - some map cells have more than one tarrain - wall and swamp for instance - lookAt returns both of them.