Why the builder screep is not moving?



  • Hello:

    I am beginner, I have just finished the tutorial and I am trying to upgrade the Room Controller, however I realized it is far from the spawn point.

    How could shorten the distance to allow the screeps reach it?

    I tried by myself to use the Construct tool. I drawed a road from the spawn to the Room Controller. However after spawning a screep with the memory 'builder' and setting its scripts for role.builder as follows:

    var roleBuilder = {

    /** @param {Creep} creep **/
    run: function(creep) {
    
        if(creep.carry.energy == 0) {
            creep.memory.building = false;
            creep.say('🔄 harvest');
        }
        if(!creep.memory.building && creep.carry.energy == creep.carryCapacity) {
            creep.memory.building = true;
            creep.say('🚧 build');
        }
    
        if(creep.memory.building) {
            var targets = creep.room.find(FIND_CONSTRUCTION_SITES);
            if(targets.length) {
                if(creep.build(targets[0]) == ERR_NOT_IN_RANGE) {
                    creep.moveTo(targets[0], {visualizePathStyle: {stroke: '#ffffff'}});
                }
            }
        }
        else {
            var sources = creep.room.find(FIND_SOURCES);
            if(creep.harvest(sources[0]) == ERR_NOT_IN_RANGE) {
                creep.moveTo(sources[0], {visualizePathStyle: {stroke: '#ffaa00'}});
            }
        }
    }
    

    };

    module.exports = roleBuilder;

    I have found that it does not move. Why?

    Thank you for your time and help.



  • You'll probably get the fastest response to your question on slack in the #help channel.

    https://screeps.slack.com



  • Do you have code in your main run loop that will trigger the Builder.run() if the creep's role is set to builder? Just including the module will do nothing by itself.

    And yes, hop on to slack so w can help you in real time, if you haven't done so yet.



  • Hi,

    Controller is kind of special. Read this. https://docs.screeps.com/api/#Creep.upgradeController

    Also, it is a good idea to check your code with "console.log". Especially if something is not working. If you check your targets variable you will see that it is empty. Room Controller is not a construction site.

    In the beginning it is very frustrating, because the game is very complex, but it will get better 🙂