This commit is contained in:
Philipp Horstenkamp 2022-04-09 17:43:36 +02:00
commit a34aad0a55
Signed by: Philipp
GPG Key ID: DD53EAC36AFB61B4
1 changed files with 17 additions and 0 deletions

17
main.mjs Normal file
View File

@ -0,0 +1,17 @@
import { prototypes, utils, constants } from '/game';
export function loop() {
var creep = utils.getObjectsByPrototype(prototypes.Creep).find(i => i.my);
var source = utils.getObjectsByPrototype(prototypes.Source)[0];
var spawn = utils.getObjectsByPrototype(prototypes.StructureSpawn).find(i => i.my);
if(creep.store.getFreeCapacity(constants.RESOURCE_ENERGY)) {
if(creep.harvest(source) == constants.ERR_NOT_IN_RANGE) {
creep.moveTo(source);
}
} else {
if(creep.transfer(spawn, constants.RESOURCE_ENERGY) == constants.ERR_NOT_IN_RANGE) {
creep.moveTo(spawn);
}
}
}