mirror of
https://github.com/clusterio/clusterio.git
synced 2026-11-24 08:23:12 +09:00
researchSync: Tried to avoid errors when research doesn't exist
This commit is contained in:
1 parent
7a4ea69cbb
commit
c8f2a67845
3 files changed
+51
-5
No files matched your search
@@ -8,7 +8,8 @@ class ResearchSync {
|
||||
this.functions = this.loadFunctions();
|
||||
this.config = slaveConfig;
|
||||
this.messageInterface = messageInterface;
|
||||
|
||||
console.log = messageInterface;
|
||||
|
||||
this.research = {};
|
||||
|
||||
messageInterface("ResearchSync enabled");
|
||||
@@ -26,7 +27,7 @@ class ResearchSync {
|
||||
doSync() {
|
||||
needle.post(this.config.masterIP + ':' + this.config.masterPort + '/api/getSlavesMeta', {
|
||||
password: this.config.clientPassword,
|
||||
}, function (err, resp, body) {
|
||||
}, (err, resp, body) => {
|
||||
if (err) throw err;
|
||||
|
||||
if (resp.statusCode != 200){
|
||||
@@ -50,7 +51,12 @@ class ResearchSync {
|
||||
|
||||
Object.keys(difference).forEach((key) => {
|
||||
if (difference[key] == 1) {
|
||||
this.messageInterface("/c game.forces['player'].technologies['" + key + "'].researched=true");
|
||||
let command = this.functions.enableResearch;
|
||||
while(command.includes("£key")){
|
||||
command = command.replace("£key", key);
|
||||
}
|
||||
this.messageInterface(command);
|
||||
// this.messageInterface("/c game.forces['player'].technologies['" + key + "'].researched=true");
|
||||
}
|
||||
})
|
||||
|
||||
@@ -62,7 +68,7 @@ class ResearchSync {
|
||||
}, function (err, resp) {
|
||||
// success?
|
||||
});
|
||||
}.bind(this));
|
||||
});
|
||||
}
|
||||
|
||||
diff(array1, array2) {
|
||||
@@ -77,7 +83,8 @@ class ResearchSync {
|
||||
|
||||
loadFunctions() {
|
||||
return {
|
||||
dumpResearch: this.loadFunc("dumpResearch.lua")
|
||||
dumpResearch: this.loadFunc("dumpResearch.lua"),
|
||||
enableResearch: this.loadFunc("enableResearch.lua"),
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user