gpt4 book ai didi

javascript - 游戏 Screeps - creep.room.find(Game.CONSTRUCTION_SITES);不工作

转载 作者:行者123 更新时间:2023-11-29 10:13:52 24 4
gpt4 key购买 nike

我有教程中的以下代码,但在模拟模式下它不起作用..

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]);
}
}
}

在控制台中打印“目标”的结果,响应未定义。谁能解释“CONSTRUCTION_SITES”常量是如何工作的以及如何在房间内找到它们?

最佳答案

代码在我看来是正确的,似乎您实际上没有为构建器构建的任何构造集。例如,您是否使用左侧的“构建”菜单来构建道路?

关于javascript - 游戏 Screeps - creep.room.find(Game.CONSTRUCTION_SITES);不工作,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27068361/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com