【发布时间】:2015-09-05 16:06:24
【问题描述】:
我想迭代找到的结构,但我不知道哪种方式最适合。
我试过这个:
for (var ext in creep.room.find(FIND_MY_STRUCTURES, {filter: { structureType: STRUCTURE_EXTENSION }})){
console.log(ext.energy);
}
但它不起作用。
所以现在我正在使用一种可行的方法,但它看起来很丑:
for(var i = 0; i < creep.room.find(FIND_MY_STRUCTURES, {filter: { structureType: STRUCTURE_EXTENSION }}).length; i++) {
var ext = creep.room.find(FIND_MY_STRUCTURES, {filter: { structureType: STRUCTURE_EXTENSION }})[i];
console.log(ext.energy);
}
我不确定,也许这是一个与js有关的问题。我是 js 的新手。您能就此提出建议吗?
【问题讨论】:
标签: javascript screeps