How to use the roads.connect function in roads

To help you get started, we’ve selected a few roads examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github jerroydmoore / screeps-ai / struct-base.js View on Github external
roadList = [];
            
            for(let pos of freePOSs) {
                // console.log(`Building ${this.structureType} ${howmanyToBuild}:${howmanyHere} at ${pos}`);
                if (BuildOrders.schedule(room, this.structureType, pos)) {
                    howmanyToBuild--;
                    howmanyHere++;
                    roadList.push(pos); // build a road to the structure so creeps can charge it.
                }
                
                if (howmanyToBuild === 0 || howmanyHere === this.howmanyAtEachPoi) {
                    break; // we have built enough or want to move onto the next POI
                }
            }

            Roads.connect(target, roadList);
            if (howmanyToBuild === 0) { 
                // don't need the rest of the POI locations.
                break;
            }
        }
        if (howmanyToBuild) {
            console.log(`Unable to build ${howmanyToBuild} ${this.structureType}(s) in ${room}`);
        }
        return howmanyToBuild === 0;
    }
    gc() {
github jerroydmoore / screeps-ai / struct-spawner.js View on Github external
console.log(`${spawner} coming online in ${spawner.room}`);
            spawner.memory.setup = 1; // only setup once
            spawner.memory.level = spawner.room.controller.level;
            
            // create a creep immediately
            roleHarvester.spawn(spawner);
        } 
        if(spawner.memory.level !== spawner.room.controller.level) {
            // We can build things!
            spawner.memory.level = spawner.room.controller.level;

            if (spawner.memory.setup < 2) {
                // Create network of roads to common places
                console.log('Create Network of Roads');
                let sources = spawner.room.find(FIND_SOURCES);
                Roads.connect(spawner, sources);
                Roads.connect(spawner.room.controller, sources);
                spawner.memory.setup = 2;
            }
        }

        // Do not have all spawners run on the same tick.
        if (Game.time % phase.SpawnPeriod == spawner.name[spawner.name.length-1]) {

            if (spawner.spawning) return;

            if (roleHarvester.shouldSpawn(spawner)) {
                roleHarvester.spawn(spawner);
            } else if (roleMiner.shouldSpawn(spawner)) {
                roleMiner.spawn(spawner);
            } else if (roleBuilder.shouldSpawn(spawner)) {
                roleBuilder.spawn(spawner);
github jerroydmoore / screeps-ai / struct-spawner.js View on Github external
spawner.memory.setup = 1; // only setup once
            spawner.memory.level = spawner.room.controller.level;
            
            // create a creep immediately
            roleHarvester.spawn(spawner);
        } 
        if(spawner.memory.level !== spawner.room.controller.level) {
            // We can build things!
            spawner.memory.level = spawner.room.controller.level;

            if (spawner.memory.setup < 2) {
                // Create network of roads to common places
                console.log('Create Network of Roads');
                let sources = spawner.room.find(FIND_SOURCES);
                Roads.connect(spawner, sources);
                Roads.connect(spawner.room.controller, sources);
                spawner.memory.setup = 2;
            }
        }

        // Do not have all spawners run on the same tick.
        if (Game.time % phase.SpawnPeriod == spawner.name[spawner.name.length-1]) {

            if (spawner.spawning) return;

            if (roleHarvester.shouldSpawn(spawner)) {
                roleHarvester.spawn(spawner);
            } else if (roleMiner.shouldSpawn(spawner)) {
                roleMiner.spawn(spawner);
            } else if (roleBuilder.shouldSpawn(spawner)) {
                roleBuilder.spawn(spawner);
            } else if (roleUpgrader.shouldSpawn(spawner)) {

roads

An isomophic http framework

MIT
Latest version published 3 years ago

Package Health Score

36 / 100
Full package analysis