mirror of
https://github.com/clusterio/clusterio.git
synced 2026-11-25 00:23:12 +09:00
Fixed scenario_loader
This commit is contained in:
1 parent
d7bfc2193e
commit
0c9ed582cc
1 file changed
+11
-18
@@ -42,25 +42,8 @@ module.exports = class remoteCommands {
|
|||||||
data,
|
data,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
let fileMap = await loadFiles("", scenPath);
|
|
||||||
let files = {};
|
|
||||||
fileMap.forEach(map => {
|
|
||||||
files[map.name] = map.data;
|
|
||||||
console.log(map.name);
|
|
||||||
});
|
|
||||||
|
|
||||||
let fileImportString = `\{`;
|
|
||||||
for(let k in files){
|
|
||||||
let name = k.replace(/\\/g, '/');
|
|
||||||
name = name.replace(/ /g, '');
|
|
||||||
// make sure *not* to include control.lua as it is provided as a seperate argument
|
|
||||||
if(name != "control") fileImportString += `["${name}"] = '${files[k]}', `;
|
|
||||||
}
|
|
||||||
fileImportString += `\}`;
|
|
||||||
if(files.control) var returnValue = await messageInterface(`/silent-command remote.call('hotpatch', 'update', '${scenarios[i]}', '1.0.0', '${files.control}', ${fileImportString})`);
|
|
||||||
if(returnValue) messageInterface(returnValue);
|
|
||||||
messageInterface(`Loaded scenario ${scenarios[i]} in ${Math.floor(Date.now()-startTime)}ms`);
|
|
||||||
}
|
}
|
||||||
|
return returnFiles;
|
||||||
}
|
}
|
||||||
let fileMap = await loadFiles("", scenPath);
|
let fileMap = await loadFiles("", scenPath);
|
||||||
let files = {};
|
let files = {};
|
||||||
@@ -120,4 +103,14 @@ class AsyncArray extends Array {
|
|||||||
super(arr)
|
super(arr)
|
||||||
this.data = arr; // In place of Array subclassing
|
this.data = arr; // In place of Array subclassing
|
||||||
}
|
}
|
||||||
|
async filterAsync(predicate) {
|
||||||
|
// Take a copy of the array, it might mutate by the time we've finished
|
||||||
|
const data = Array.from(this.data);
|
||||||
|
// Transform all the elements into an array of promises using the predicate
|
||||||
|
// as the promise
|
||||||
|
const result = await Promise.all(data.map((element, index) => predicate(element, index, data)));
|
||||||
|
return data.filter((element, index) => {
|
||||||
|
return result[index];
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
Reference in new issue
Block a user