-
Notifications
You must be signed in to change notification settings - Fork 0
/
modern_transporter.js
62 lines (60 loc) · 2.53 KB
/
modern_transporter.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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
var modern_transporter = {
run: function(creep, _idget, _idput, _type, _forcemove, _back) {
creep.heal(creep);
if(creep.ticksToLive < 250 && creep.store.getUsedCapacity() == 0) {creep.suicide();}
if(creep.memory.transport && creep.store.getUsedCapacity() == 0) {
creep.memory.transport = false;
}
if(!creep.memory.transport && creep.store.getFreeCapacity() == 0) {
creep.memory.transport = true;
}
var source = Game.getObjectById(_idget);
if(source == undefined) {
creep.say("No Visual");
return;
}
if(_type != 'ALL'){
if(_forcemove == true || source.store.getUsedCapacity(_type) == 0) creep.memory.transport = true;
}
else{
if(_forcemove == true || source.store.getUsedCapacity() == 0) creep.memory.transport = true;
}
if(creep.memory.transport || _back == true) {
var str = Game.getObjectById(_idput);
if(_type == 'ALL') {
for(var name of RESOURCES_ALL) {
if(creep.store.getUsedCapacity(name) > 0) {
if(creep.transfer(str,name) == ERR_NOT_IN_RANGE) {
creep.moveTo(str, {visualizePathStyle: {stroke: '#f6b352', opacity: .5, reusePath: 50}});
}
}
}
}
else {
var str = Game.getObjectById(_idput);
if(creep.transfer(str, _type) == ERR_NOT_IN_RANGE) {
creep.moveTo(str, {visualizePathStyle: {stroke: '#f6b352', opacity: .5, reusePath: 50}});
}
}
}
else {
var str = Game.getObjectById(_idget);
if(_type == 'ALL') {
for(var name of RESOURCES_ALL) {
if(str.store.getUsedCapacity(name) > 0) {
if(creep.withdraw(str,name) == ERR_NOT_IN_RANGE) {
creep.moveTo(str, {visualizePathStyle: {stroke: '#f6b352', opacity: .5, reusePath: 50}});
}
}
}
}
else {
var str = Game.getObjectById(_idget);
if(creep.withdraw(str,_type) == ERR_NOT_IN_RANGE) {
creep.moveTo(str, {visualizePathStyle: {stroke: '#f6b352', opacity: .5, reusePath: 50}});
}
}
}
}
};
module.exports = modern_transporter;