how to find a SPAWN?



  • Spawns do not appear to be listed as structures and there cannot FIND_STUCURES and filter to Spawn. How do I find a Spawn if I want to attack another players?



  • Nevermind I'll figure it out. The game is great. Trying to figuring basic stuff out, is not so. Should be able to edit or delete postings.



  • You're looking for http://support.screeps.com/hc/en-us/articles/203016392-Spawn which is referenced with Game.spawns.nameOfSpawn or my favorite for(var x in Game.spawns) {Game.spawns[x]; //Touches every spawn}

    Not sure if a documentation error but you can reference constructionSite.structureType == STRUCTURE_SPAWN but not from structure. Not sure why.



  • If attacking other players doing a find from the room works if you can reference the room, usually from your unit being inside the room you can do the following:

            var targetSpawn = CREEP_REFERENCE.room.find(FIND_HOSTILE_SPAWNS);
            if(targetSpawn .length)
            {
                if(CREEP_REFERENCE.attack(targetSpawn [0]) == ERR_NOT_IN_RANGE)
                {
                    CREEP_REFERENCE.moveTo(targetSpawn[0]);
                }
            }
    

    or go through a loop of all found spawns and attack them all.



  • Thank you.