From fdf8a4b4b1823d0edd9888a53375b295e6593edd Mon Sep 17 00:00:00 2001 From: Danielv123 Date: Wed, 14 Jun 2017 21:52:38 +0200 Subject: [PATCH] Housekeeping --- sharedPlugins/inventoryImports/index.js | 6 +----- sharedPlugins/inventoryImports/interfacingFunctions.js | 6 +++--- 2 files changed, 4 insertions(+), 8 deletions(-) diff --git a/sharedPlugins/inventoryImports/index.js b/sharedPlugins/inventoryImports/index.js index e2021066..32c88bc3 100644 --- a/sharedPlugins/inventoryImports/index.js +++ b/sharedPlugins/inventoryImports/index.js @@ -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){ diff --git a/sharedPlugins/inventoryImports/interfacingFunctions.js b/sharedPlugins/inventoryImports/interfacingFunctions.js index 04e0394a..c3d73e62 100644 --- a/sharedPlugins/inventoryImports/interfacingFunctions.js +++ b/sharedPlugins/inventoryImports/interfacingFunctions.js @@ -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); });