Skip to content

Commit b5ef13f

Browse files
committed
Fixed launching and added comments
1 parent 8956581 commit b5ef13f

File tree

1 file changed

+10
-7
lines changed

1 file changed

+10
-7
lines changed

index.js

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -92,8 +92,9 @@ ipc.on("launchFactorio", function(event, data){
9292
// when connected disconnect
9393
client.on('connected', function () {
9494
console.log('Connected!');
95-
console.log('RCON confirmed!');
96-
// download mods
95+
console.log('RCON confirmed, downloading mods...');
96+
97+
// delete mods we don't want
9798
let installedMods = fs.readdirSync("factorio/mods/")
9899
for(let i = 0; i < installedMods.length; i++){
99100
let x = false;
@@ -103,19 +104,21 @@ ipc.on("launchFactorio", function(event, data){
103104
}
104105
}
105106
if (!x) {
106-
console.log("Deleting: " + installedMods[i])
107-
fs.unlinkSync("factorio/mods/"+installedMods[i])
107+
console.log("Deleting: " + installedMods[i]);
108+
// Unlink is how you delete files in node
109+
fs.unlinkSync("factorio/mods/"+installedMods[i]);
108110
}
109111

110112
}
113+
114+
// download mods we don't have
111115
let counter = 0;
112116
for(let key in data.mods) {
113117
if(fs.existsSync("factorio/mods/"+data.mods[key].modName)){
114118
console.log("Installed: " + data.mods[key].modName);
115119
} else {
116120
console.log("Downloading: " + data.mods[key].modName);
117121
download("http://"+config.get("masterAddress")+"/"+data.mods[key].modName, "factorio/mods/"+data.mods[key].modName, launch(data.mods[key].modName));
118-
console.log("Downloaded: " + data.mods[key].modName);
119122
}
120123
}
121124
function launch(modName) {
@@ -124,9 +127,9 @@ ipc.on("launchFactorio", function(event, data){
124127
if(counter == data.mods.length) {
125128
//spawn factorio and tell it to connect to a server directly
126129
console.log("Starting factorio...");
127-
/*var gameprocess = child_process.spawn("factorio/bin/x64/factorio", [
130+
var gameprocess = child_process.spawn("factorio/bin/x64/factorio", [
128131
"--mp-connect", data.ip+":"+data.port,
129-
]);*/
132+
]);
130133
}
131134
}
132135

0 commit comments

Comments
 (0)