-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathautomdrone.js
36 lines (29 loc) · 905 Bytes
/
automdrone.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
const body = [WORK,WORK,WORK,WORK,WORK,WORK,WORK,WORK];
module.exports = {
run: function (roomName) {
var room = Game.rooms[roomName];
var mineral = Game.rooms[roomName].find(FIND_MINERALS);
const creepName = 'mdrone_' + roomName;
var creep = Game.creeps[creepName];
if (!creep) {
autoSpawnCreep(creepName, roomName);
}
else {
}
}
}
function autoSpawnCreep(creepName, roomName) {
var spawn = getAvaliableSpawn(roomName);
if (spawn) {
spawn.spawnCreep(body, creepName, {memory: {role: 'mdrone' }});
}
}
function getAvaliableSpawn(room) {
for (var spawnname in Game.spawns) {
var spawn = Game.spawns[spawnname];
if (spawn.room.name == room && spawn.spawning == null) {
return spawn;
}
}
return null;
}