Room navigation solutions?



  • Has anyone found a good way to navigate through the rooms in code? I tried looping through Game.rooms but was only getting rooms I already had creeps in. I can't find a good way to get an adjacent room's name. I also tried using Game.map.describeExits but I am only seeing the directions and cannot find a way to get the room name from it.

    //only see rooms I already occupy
    for(var name in Game.rooms) {
    var myRoom = Game.rooms[name];
    }

    //not seeing the name property populated for exit object
    for(var exit in exits){
    console.log(exit);
    console.log(exit.name);
    }


  • Culture

    If you really need the room name you can just take the current room and manipulate the numbers/directions.

    However Game.rooms for that room will not be accessible for you unless you have some sort of presence in it.

    If you're trying to navigate to the room then using

    creep.pos.findClosest(creep.room.findExitTo(roomName))

    is sufficient. The findClosest function is intelligent enough to know it's a room direction and will move there.



  • if (Game.spawns[spawn].memory.exitsfromhome[3] != undefined)
    {
    console.log(Game.spawns[spawn].memory.exitsfromhome[3]);
    }

    Puts out W7N3.

    well, you have to get it with the [ ] is what I am saying. It's in my spawns memory, don't ask ^^

     

    It took you people 18 months to tell this poor sod that 😞



  • Your data is coming from memory, which your code must populate from somewhere within your code.  It's not available to other people that aren't using your code base.