Garethp / Screeps

95 stars 40 forks source link

Screep Newbie Question #2

Open InternetMedicineMan opened 9 years ago

InternetMedicineMan commented 9 years ago

Hello. I'm new to Screeps and I found your scripts. When I start it up I'm trying to make it work but continually just keep getting this error:

TypeError: Cannot read property 'find' of null at module.exports (countType:9:18) at Object.module.exports.spawnRequiredScreeps (factory:79:16) at Object.module.exports.run (factory:15:8) at main:7:9

I'm trying to read through the code and see how I might initialize the creeps but it seems as though there is a factory function that should be working, but it never actually starts the Factory because trying to find creeps on a blank board is erroring out. Trying to spawn one still comes up with the same errors.

I'll keep looking but I'm missing something. Any help would be appreciated.

WelpThatWorked commented 7 years ago

I am having a the same issue, trying to find where it comes from

Garethp commented 7 years ago

It looks like the error is coming because this script was written for the tutorial, long long ago. The error is coming from

var room = Game.getRoom('1-1');

    var count = room.find(Game.MY_CREEPS, {
        filter: function(creep)
        {
            if(creep.memory.role == type)
                return true;

            return false;
        }
    }).length;

Where room is null, so room.find raises an error. Maybe the room name in Game.getRoom() is wrong, or the way to get the room is wrong. I'm not sure how it's done any more, I haven't played screeps since before it went live

theskull4028 commented 7 years ago

is there any way that these modules will be updates/fixed?

Garethp commented 7 years ago

Probably not. And if it does, it'll likely just be replaced instead of updated