diff --git a/c-inv_0.0.2/control.lua b/c-inv_0.0.2/control.lua index 29973d6e..994ccf7a 100644 --- a/c-inv_0.0.2/control.lua +++ b/c-inv_0.0.2/control.lua @@ -211,7 +211,7 @@ end function ExportOutputList() local exportStrings = {} for k,v in pairs(global.outputList) do - exportStrings[#exportStrings + 1] = k..", "..v.."\n" + exportStrings[#exportStrings + 1] = k.." "..v.."\n" end global.outputList = {} if #exportStrings > 0 then diff --git a/client.js b/client.js index 3db7012b..a0c2df60 100644 --- a/client.js +++ b/client.js @@ -1,23 +1,26 @@ var fs = require('fs'); var needle = require("needle") -var Rcon = require('rcon') // connect us to the server with rcon // IP, port, password -var conn = new Rcon('localhost', 12345, '123'); -conn.on('auth', function() { - console.log("Authed!"); - -}).on('response', function(str) { - console.log("Got response: " + str); - -}).on('end', function() { - console.log("Socket closed!"); - process.exit(); +var Rcon = require('simple-rcon'); +var client = new Rcon({ + host: '81.167.2.56', + port: '12345', + password: '123', + timeout: 0 +}).connect(); +client.on('authenticated', function() { + console.log('Authenticated!'); +}).on('connected', function() { + console.log('Connected!'); +}).on('disconnected', function() { + console.log('Disconnected!'); + // now reconnect + client.connect(); }); -conn.connect(); // trigger when something happens to output.txt fs.watch("Factorio 0.13.9/script-output/output.txt", "utf8", function(eventType, filename) { @@ -52,12 +55,13 @@ fs.watch("Factorio 0.13.9/script-output/orders.txt", "utf8", function(eventType, if(items[i]) { g = items[i].split(" "); g[0] = g[0].replace("\u0000", ""); + g[0] = g[0].replace(",", ""); console.log(g); // send our entity and count to the master for him to keep track of needle.post('localhost:8080/remove', {name:g[0], count:g[1]}, function(err, resp, body){ console.log(body); if(body){ - //conn.send("/c remote.call('clusterio', 'import', '" + g[0] + "', " + g[1] + ")") + client.exec("/c remote.call('clusterio', 'import', '" + g[0] + "', " + g[1] + ")") } }); } diff --git a/launchEverything.bat b/launchEverything.bat index 675bbac9..30e170f6 100644 --- a/launchEverything.bat +++ b/launchEverything.bat @@ -1,19 +1,15 @@ -start nodemon client.js -start nodemon master.js - -cd "Factorio 0.13.9 - Copy/bin/x64" -start factorio.exe -cd .. -cd .. -cd .. - cd "Factorio 0.13.9" @RD /S /Q "temp" -cd "bin/x64" -start factorio.exe --start-server-load-latest --rcon-port 12345 --rcon-password 123 --server-settings server-settings.json --no-auto-pause +cd "bin/x64/" +start factorio.exe --start-server-load-latest --rcon-port 12345 --rcon-password 123 --server-settings server-settings.json --no-auto-pause cd .. cd .. cd .. -@mcrcon.exe -t -H 81.167.2.56 -P 12345 -p 123 + +start cmd /C node client.js +start cmd /C node master.js + +::cd "Factorio 0.13.9 - Copy/bin/x64" +::@start factorio.exe pause \ No newline at end of file