From a34aad0a559139c7a14e8daec4b6568c5d98b215 Mon Sep 17 00:00:00 2001 From: Philipp Horstenkamp Date: Sat, 9 Apr 2022 17:43:36 +0200 Subject: [PATCH] init --- main.mjs | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) create mode 100644 main.mjs diff --git a/main.mjs b/main.mjs new file mode 100644 index 0000000..fa7281f --- /dev/null +++ b/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); + } + } +} \ No newline at end of file