私は、自分のrole.builders.jsファイルを少し変えて、creepsが最初にエバリーを持っているかどうかを確認し、エネルギーを蓄えていなければそれを取得します。産卵する。ここに私が持っているものがあります:Screeps Builderがエネルギーを集めない
var roleBuilder = {
/** @param {Creep} creep **/
run: function(creep) {
if(creep.memory.building && creep.carry.energy == 0) {
creep.memory.building = false;
creep.say('harvesting');
}
if(!creep.memory.building && creep.carry.energy == creep.carryCapacity) {
creep.memory.building = true;
creep.say('building');
}
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]);
}
}
}
else
{
if(!Game.spawns['MySpawn'].energy)
{
var sources = creep.room.find(FIND_SOURCES);
if(creep.harvest(sources[0]) == ERR_NOT_IN_RANGE)
{
creep.moveTo(sources[0]);
}
}
else
{
if(creep.withdraw(Game.spawns['MySpawn'],RESOURCE_ENERGY) == ERR_NOT_IN_RANGE)
{
creep.moveTo(Game.spawns['MySpawn']);
}
}
}
}
};
module.exports = roleBuilder;
私が紛失しているものについての提案はありますか?ビルダーは、スポーンに移動していると言われても、固定されています。
私は修正を見つけました: '\t var spns = creep.room.find(FIND_MY_SPAWNS); \t if(creep.withdraw(spns [0]、RESOURCE_ENERGY)== ERR_NOT_IN_RANGE) \t { \t creep.moveTo(spns [0]); \t} \t他 \t {\t creep.withdraw(SPNの[0]、RESOURCE_ENERGY)。 \t} ' – user1971240