Current script (thx th_pion for base)

github.com/thPion/Screeps-Nooby-Guide
This commit is contained in:
2018-05-17 12:01:49 +02:00
parent 67a1270663
commit 220a110ae1
13 changed files with 807 additions and 0 deletions

35
src/main.js Normal file
View File

@@ -0,0 +1,35 @@
// import modules
require('prototype.creep');
require('prototype.tower');
require('prototype.spawn');
module.exports.loop = function() {
// check for memory entries of died creeps by iterating over Memory.creeps
for (let name in Memory.creeps) {
// and checking if the creep is still alive
if (Game.creeps[name] == undefined) {
// if not, delete the memory entry
delete Memory.creeps[name];
}
}
// for each creeps
for (let name in Game.creeps) {
// run creep logic
Game.creeps[name].runRole();
}
// find all towers
var towers = _.filter(Game.structures, s => s.structureType == STRUCTURE_TOWER);
// for each tower
for (let tower of towers) {
// run tower logic
tower.defend();
}
// for each spawn
for (let spawnName in Game.spawns) {
// run spawn logic
Game.spawns[spawnName].spawnCreepsIfNecessary();
}
};