Skip to content

Instantly share code, notes, and snippets.

@Hernanduer
Created October 26, 2015 04:52
Show Gist options
  • Save Hernanduer/cd209bc0e0728a0503ea to your computer and use it in GitHub Desktop.
Save Hernanduer/cd209bc0e0728a0503ea to your computer and use it in GitHub Desktop.
'use strict';
var hooks = require('hooks');
var autospawn = require("autospawn");
var minerFunc = require("miner");
var transporterFunc = require("transporter");
var builderFunc = require('builder');
var upgraderFunc = require('upgrader');
var janitorFunc = require('janitor');
var repairerFunc = require("repairer");
var shuttleFunc = require("shuttle");
var defenderFunc = require("defender");
var linkerFunc = require("linker");
var creepWork = require("creep");
var mining = require("mining");
var roadworkerFunc = require("roadworker");
var energyLog = require("logThisEveryTick");
var controllerStatus = require("controllerStatus");
var scoutFunc = require("scout");
module.exports.loop = function () {
//Spawner
for (var name in Memory.creeps) {
if (!Game.creeps[name]) {
delete Memory.creeps[name];
}
}
hooks();
for (var i in Game.creeps) {
if (Game.creeps[i].spawning == true || Memory.creeps[i] == undefined) continue;
let creep = Game.creeps[i];
let role = creep.memory.role;
Memory.bots[Memory.creeps[name].role].push(name);
if (Memory.transporter > Memory.bots.miner.length) {
Memory.transporter = 0;
}
if (role === 'miner') {
minerFunc(creep);
}
else if (role === 'transporter') {
if(!creep.memory.modulo){
creep.memory.modulo = Memory.couriers;
Memory.transporter++;
}
transporterFunc(creep);
}
else if (role === 'builder') {
builderFunc(creep);
}
else if (role === 'upgrader') {
upgraderFunc(creep);
}
else if (role === 'janitor') {
janitorFunc(creep);
}
else if (role === 'repairer') {
repairerFunc(creep);
}
else if (role === 'shuttle') {
shuttleFunc(creep);
}
else if (role === 'defender') {
defenderFunc(creep);
}
else if (role === 'linker') {
linkerFunc(creep);
}
else if (role === 'roadworker') {
roadworkerFunc(creep);
}
else if (role === 'scout') {
scoutFunc(creep);
}
}
autospawn();
/* //link transfer
let linkFrom = Game.spawns.Spawn1.room.lookForAt('structure', 42, 11)[0];
let linkTo = Game.spawns.Spawn1.room.lookForAt('structure', 15, 34)[0];
if (linkFrom.energy === linkFrom.energyCapacity) {
linkFrom.transferEnergy(linkTo);
}
*/
/* //Miner to flag
let storageConfig = {
x: 28,
y: 17
};
let config = {
miningFlag: "FlagBottom",
minerCount: 1,
courierCount: 1,
destRoom: "W11S19",
storage: storageConfig
};
mining(config);
*/
energyLog();
if (Game.time % 300 == 0) {
controllerStatus();
}
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment