ich nicht ganz sicher über Ihr Problem sein kann, da ich Ihren vollständigen Code nicht weg zu gehen von nur einem Problem könnte sein, dass creep
nicht definiert ist.
Sie müssen irgendwo in Ihrem Code creep
wie eine for-Schleife definieren, um über jedes Ihrer Creeps im Spiel oder im Raum zu schleifen.
var roleMiner = require('role.miner') // role.miner being the module name for miner actions
for(var name in Game.creeps) {
var creep = Game.creeps[name];
//
// do whatever you wish with the current selected creep.
//
// most of the time you will call a module similar to what the tutorials suggest and put your actions for it in there
//
if(creep.memory.role == 'miner'){
roleMiner.run(creep); // passes the current selected creep to the run function in the module
}
}
Also, in Ihrem Roleminer Modul haben Sie etwas, das Ihre Bergarbeiter Aktionen definiert.
var roleMiner = {
run: function(creep) {
// this one returns an array of the sources that are in the room with the creep
var sourcesRoom = creep.room.find(FIND_SOURCES);
// this one returns the source object which is closest to the creeps positon
var sourcesClose = creep.pos.findClosestByRange(FIND_SOURCES);
}
}
module.exports = roleMiner;
Hoffe das hilft.
Können Sie mehr Kontext bereitstellen? Es ist möglich, dass "Kriechen" gar nicht einmal ein "Kriechen" ist, weshalb "Kriechen" undefiniert ist. –