Game Screeps - creep.room.find(Game.CONSTRUCTION_SITES); not working

javascript, screeps

Solution

The code looks right to me, it seems that you don't actually have any constructions set for the builders to build. Did you use the "Construct" menu on the left to build a road, for example?

Problem

I have the following code from the tutorial, except in simulation mode it isn't working.. ``` if(creep.memory.role == 'builder') { if(creep.energy === 0) { creep.moveTo(Game.spawns.Spawn1); Game.spawns.Spawn1.transferEnergy(creep); } else { var targets = creep.room.find(Game.CONSTRUCTION_SITES); if(targets.length) { creep.moveTo(targets[0]); creep.build(targets[0]); } } } ``` Printing the result of "targets" in the console, responds undefined. Can anyone explain how the "CONSTRUCTION_SITES" constant is working and how to find them inside the room?

Original source