我是Screeps的新手(喜欢它),我很难为房间中的所有源创建变量。 我想,以确保只有3个小兵相同的源上工作,所以我下面的代码片段为我的收获,我的主模块screeps - 无法在源代码中创建变量
主要
var sources = Game.spawns.Spawn1.room.find(FIND_SOURCES);
for (var a in sources) {
var source = (sources[a]);
source.memory.numPeopleAt = 0;
}
module.exports.loop = function() {
...
}
收割机
var sources = creep.room.find(FIND_SOURCES);
for (var s in sources) {
if (creep.harvest(sources[s]) == ERR_NOT_IN_RANGE && sources[s].memory.numPeopleAt < 3) {
creep.moveTo(sources[s]);
sources[s].memory.numPeopleAt++;
break;
}
}
我知道我还是要做一个功能sources[s].memory.numPeopleAtt--
在此先感谢,
杰瑞凡Melckebeke