diff --git a/c-inv_0.0.2/config.lua b/c-inv_0.0.2/config.lua index 9fa3b4b1..dfc03933 100644 --- a/c-inv_0.0.2/config.lua +++ b/c-inv_0.0.2/config.lua @@ -2,10 +2,10 @@ INPUT_CHEST_NAME = "put-chest" INPUT_CHEST_PICTURE_PATH = nil INPUT_CHEST_ICON_PATH = nil -INPUT_CHEST_FILE = "intput-items.txt" +INPUT_CHEST_FILE = "output.txt" --the chest that the player get things from OUTPUT_CHEST_NAME = "get-chest" OUTPUT_CHEST_PICTURE_PATH = nil OUTPUT_CHEST_ICON_PATH = nil -OUTPUT_CHEST_FILE = "output-items.txt" \ No newline at end of file +OUTPUT_CHEST_FILE = "orders.txt" \ No newline at end of file diff --git a/c-inv_0.0.2/control.lua b/c-inv_0.0.2/control.lua index b8c46c67..8d3a45cf 100644 --- a/c-inv_0.0.2/control.lua +++ b/c-inv_0.0.2/control.lua @@ -76,7 +76,7 @@ function HandleInputChests() local items = v.get_inventory(defines.inventory.chest).get_contents() --write everything to the file for itemName, itemCount in pairs(items) do - linesToWriteToFile[#linesToWriteToFile + 1] = itemName..", "..itemCount.."\n" + linesToWriteToFile[#linesToWriteToFile + 1] = itemName.. " " ..itemCount.."\n" end -- clear the inventory v.get_inventory(defines.inventory.chest).clear() diff --git a/client.js b/client.js index 26649615..3db7012b 100644 --- a/client.js +++ b/client.js @@ -56,8 +56,8 @@ fs.watch("Factorio 0.13.9/script-output/orders.txt", "utf8", function(eventType, // 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 == "success") { - conn.send("/c remote.call('clusterio', 'import', '" + g[0] + "', " + g[1] + ")") + if(body){ + //conn.send("/c remote.call('clusterio', 'import', '" + g[0] + "', " + g[1] + ")") } }); } diff --git a/launchEverything.bat b/launchEverything.bat index d7afe3b9..675bbac9 100644 --- a/launchEverything.bat +++ b/launchEverything.bat @@ -1,4 +1,12 @@ 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" @@ -8,10 +16,4 @@ cd .. cd .. @mcrcon.exe -t -H 81.167.2.56 -P 12345 -p 123 -pause - -cd "Factorio 0.13.9 - Copy/bin/x64" -start factorio.exe -cd .. -cd .. -cd .. \ No newline at end of file +pause \ No newline at end of file diff --git a/master.js b/master.js index 42a3e889..f13b42dc 100644 --- a/master.js +++ b/master.js @@ -56,7 +56,7 @@ db.items.removeitem = function(object) { app.post("/place", function(req, res) { res.header("Access-Control-Allow-Origin", "*"); res.header("Access-Control-Allow-Headers", "Origin, X-Requested-With, Content-Type, Accept"); - console.log(req.body); + console.log("added: " + req.body); // save items we get db.items.additem(req.body) // Attempt confirming @@ -64,12 +64,13 @@ app.post("/place", function(req, res) { }); // endpoint to remove items from DB when client orders items -app.post("/place", function(req, res) { +app.post("/remove", function(req, res) { res.header("Access-Control-Allow-Origin", "*"); res.header("Access-Control-Allow-Headers", "Origin, X-Requested-With, Content-Type, Accept"); - console.log(req.body); + console.log("removed: " + req.body); // save items we get - if(db.items.removeitem(req.body);) { + temp = db.items.removeitem(req.body); + if(temp) { // if true, the action was successfull res.send("success"); } else {