initial commit, tutorial level scripts
This commit is contained in:
@@ -0,0 +1,19 @@
|
||||
var roleHarvester = {
|
||||
|
||||
/** @param {Creep} creep **/
|
||||
run: function(creep) {
|
||||
if(creep.store.getFreeCapacity() > 0) {
|
||||
var sources = creep.room.find(FIND_SOURCES);
|
||||
if(creep.harvest(sources[0]) == ERR_NOT_IN_RANGE) {
|
||||
creep.moveTo(sources[0]);
|
||||
}
|
||||
}
|
||||
else if(Game.spawns['Spawn1'].energy < Game.spawns['Spawn1'].energyCapacity) {
|
||||
if(creep.transfer(Game.spawns['Spawn1'], RESOURCE_ENERGY) == ERR_NOT_IN_RANGE) {
|
||||
creep.moveTo(Game.spawns['Spawn1']);
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
module.exports = roleHarvester;
|
||||
Reference in New Issue
Block a user