mirror of
https://github.com/clusterio/clusterio.git
synced 2026-11-13 15:14:52 +09:00
Implement require option for modules
Implement option allowing files to be required from control.lua be specified in modules.json.
This commit is contained in:
1 parent
e89e54ee27
commit
c091dc341e
5 files changed
+45
-13
No files matched your search
@@ -82,10 +82,13 @@ function generateLoader(patchInfo) {
|
||||
|
||||
for (let module of patchInfo["modules"]) {
|
||||
for (let file of module["files"]) {
|
||||
let requirePath = `modules/${module.name}/${file["path"].slice(0, -4)}`;
|
||||
if (file["load"]) {
|
||||
let requirePath = `modules/${module.name}/${file["path"].slice(0, -4)}`;
|
||||
lines.push('event_handler.add_lib(require("'+requirePath+'"))');
|
||||
}
|
||||
if (file["require"]) {
|
||||
lines.push('require("'+requirePath+'")');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -251,6 +254,7 @@ async function patch(savePath, modules) {
|
||||
moduleInfo["files"].push({
|
||||
"path": relativePath,
|
||||
"load": module.load.includes(relativePath),
|
||||
"require": module.require.includes(relativePath),
|
||||
});
|
||||
|
||||
} else if (entry.isDirectory()) {
|
||||
|
||||
Reference in new issue
Block a user