Browse Source

init

master
Philipp Horstenkamp 4 months ago
commit
a34aad0a55
Signed by: philipp
GPG Key ID: DD53EAC36AFB61B4
  1. 17
      main.mjs

17
main.mjs

@ -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);
}
}
}
Loading…
Cancel
Save