我已經改變了一下我的role.builders.js文件,讓我的小兵先檢查一下,看看菌種是否有能力,如果它沒有收穫能量來建立,否則從產卵。這裏是我有什麼:Screeps Builders Not Gathering Energy
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);如果(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