Adding source code to respository.
This commit is contained in:
40
main.js
Normal file
40
main.js
Normal file
@@ -0,0 +1,40 @@
|
||||
|
||||
/* ######################
|
||||
# Screeps 2022 #
|
||||
######################*/
|
||||
|
||||
const spawns = require("spawns");
|
||||
const creeps = require("creeps");
|
||||
const towers = require("towers");
|
||||
const ai_main = require("ai_main");
|
||||
|
||||
const system = require("system");
|
||||
|
||||
module.exports.loop = function () {
|
||||
// New system
|
||||
if (global.started == undefined) {
|
||||
console.log("Recompiled...");
|
||||
global.started = true;
|
||||
system.start();
|
||||
}
|
||||
system.update();
|
||||
|
||||
|
||||
|
||||
// Old system
|
||||
ai_main.run();
|
||||
towers.run();
|
||||
spawns.run();
|
||||
if (Game.time % 60 == 0) {
|
||||
clear_dead_creeps_from_memory();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
function clear_dead_creeps_from_memory() {
|
||||
for (var cr in Memory.creeps) {
|
||||
if (Game.creeps[cr] == null) {
|
||||
delete (Memory.creeps[cr]);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user