mirror of
https://github.com/clusterio/clusterio.git
synced 2026-11-20 23:53:13 +09:00
Changed up the tranfer format, everything works!
This commit is contained in:
1 parent
06a4d49884
commit
1e65eb40c5
2 files changed
+29
-20
No files matched your search
@@ -55,23 +55,28 @@ setInterval(function() {
|
|||||||
if(items[0]) {
|
if(items[0]) {
|
||||||
fs.writeFileSync(config.factorioDirectory + "/script-output/orders.txt", "")
|
fs.writeFileSync(config.factorioDirectory + "/script-output/orders.txt", "")
|
||||||
for(i = 0;i < items.length; i++) {
|
for(i = 0;i < items.length; i++) {
|
||||||
if(items[i]) {
|
(function(i){
|
||||||
items[i] = items[i].split(" ");
|
if(items[i]) {
|
||||||
items[i][0] = items[i][0].replace("\u0000", "");
|
items[i] = items[i].split(" ");
|
||||||
items[i][0] = items[i][0].replace(",", "");
|
items[i][0] = items[i][0].replace("\u0000", "");
|
||||||
console.log(items)
|
items[i][0] = items[i][0].replace(",", "");
|
||||||
// send our entity and count to the master for him to keep track of
|
// send our entity and count to the master for him to keep track of
|
||||||
needle.post(config.masterIP + ":" + config.masterPort + '/remove', {name:items[i][0], count:items[i][1]}, function(err, response, body){
|
needle.post(config.masterIP + ":" + config.masterPort + '/remove', {name:items[i][0], count:items[i][1]}, function(err, response, body){
|
||||||
if(response && response.body === "successier"){
|
if(response && response.body && typeof response.body == "object") {
|
||||||
console.log(response.body + " : importing: " + JSON.stringify({[items[i][0]]: items[i][1]}));
|
// buffer confirmed orders
|
||||||
// buffer confirmed orders
|
confirmedOrders[confirmedOrders.length] = {[response.body.name]: response.body.count}
|
||||||
confirmedOrders[confirmedOrders.length] = {[items[i][0]]: items[i][1]}
|
}
|
||||||
//client.exec("/c remote.call('clusterio', 'importMany', '[" + JSON.stringify(jsonobject) + "]')")
|
/*if(response && response.body === "successier"){
|
||||||
} else {
|
console.log(response.body + " : importing: " + JSON.stringify({[items[i][0]]: items[i][1]}));
|
||||||
console.log("ERROR: "+JSON.stringify({[items[i][0]]: items[i][1]}));
|
// buffer confirmed orders
|
||||||
}
|
confirmedOrders[confirmedOrders.length] = {[items[i][0]]: items[i][1]}
|
||||||
});
|
//client.exec("/c remote.call('clusterio', 'importMany', '[" + JSON.stringify(jsonobject) + "]')")
|
||||||
}
|
} else {
|
||||||
|
console.log("ERROR: "+JSON.stringify({[items[i][0]]: items[i][1]}));
|
||||||
|
}*/
|
||||||
|
});
|
||||||
|
}
|
||||||
|
})(i);
|
||||||
}
|
}
|
||||||
// if we got some confirmed orders
|
// if we got some confirmed orders
|
||||||
console.log("Importing " + confirmedOrders.length + " items! " + JSON.stringify(confirmedOrders));
|
console.log("Importing " + confirmedOrders.length + " items! " + JSON.stringify(confirmedOrders));
|
||||||
|
|||||||
@@ -67,9 +67,13 @@ app.post("/remove", function(req, res) {
|
|||||||
// Update existing items if item name already exists
|
// Update existing items if item name already exists
|
||||||
if(Number(doc.count) > Number(object.count)) {
|
if(Number(doc.count) > Number(object.count)) {
|
||||||
console.log("removed: " + object.name + " " + object.count + " . " + doc.count);
|
console.log("removed: " + object.name + " " + object.count + " . " + doc.count);
|
||||||
object.count = Number(doc.count) - Number(object.count);
|
objectUpdate = {
|
||||||
db.items.update(doc, object, {multi:true}, function (err, numReplaced) {});
|
"name": object.name,
|
||||||
res.send("successier");
|
"count": Number(doc.count) - Number(object.count),
|
||||||
|
};
|
||||||
|
db.items.update(doc, objectUpdate, {multi:true}, function (err, numReplaced) {});
|
||||||
|
// res.send("successier");
|
||||||
|
res.send(object);
|
||||||
} else {
|
} else {
|
||||||
console.log('failure');
|
console.log('failure');
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in new issue
Block a user