mirror of
https://github.com/clusterio/clusterio.git
synced 2026-11-12 15:04:52 +09:00
Housekeeping
This commit is contained in:
1 parent
c4ead8c699
commit
fdf8a4b4b1
2 files changed
+4
-8
No files matched your search
@@ -12,12 +12,8 @@ process.stdin.on('readable', () => {
|
||||
var chunk = process.stdin.read();
|
||||
// console.log(chunk)
|
||||
if (chunk !== null && isNaN(chunk) && config && isJson(chunk) && !JSON.parse(chunk).factorioPort){
|
||||
// example chunk Stdout: {1:{inventory:{['iron-ore']:100,['steel-plate']:5800,['iron-ore']:50,},
|
||||
// requestSlots:{['underground-belt']:50, ['fast-transport-belt']:50, ['express-underground-belt']:50, ['underground-belt']:50, }},}
|
||||
// returns JS object, throws if there are syntax errors in input string
|
||||
// let inventory = functions.parseJsString(chunk);
|
||||
|
||||
let inventory = JSON.parse(chunk)
|
||||
// console.log(inventory);
|
||||
// process inventory of players and ask master for more stuff
|
||||
functions.handleInventory(inventory, config);
|
||||
} else if(isJson(chunk) && JSON.parse(chunk).factorioPort){
|
||||
|
||||
@@ -14,8 +14,8 @@ function parseJsString(string){
|
||||
}
|
||||
let inventory = "";
|
||||
eval("inventory = " + string);
|
||||
console.log(string)
|
||||
console.log(inventory)
|
||||
/*console.log(string)
|
||||
console.log(inventory)*/
|
||||
return inventory;
|
||||
/* Example output:
|
||||
{'1':{
|
||||
@@ -119,7 +119,7 @@ function handleInventory(json, config){
|
||||
let stackArray = json.exports[playerName];
|
||||
for(let i = 0; i < stackArray.length; i++){
|
||||
if(stackArray[i].count > 0){
|
||||
console.log("Returning overflow: " + JSON.stringify(stackArray[i]));
|
||||
// console.log("Returning overflow: " + JSON.stringify(stackArray[i]));
|
||||
needle.post(config.masterIP + ":" + config.masterPort + '/api/place', stackArray[i], function (err, resp, body) {
|
||||
// console.log(body);
|
||||
});
|
||||
|
||||
Reference in new issue
Block a user