If you would like to use separate files for obvious reasons or not too much.
Code:
Before usage you must download Node.js and then, in command prompt (or cmd/terminal) run
.
After that save the code I gave you, in your command prompt (or cmd/terminal) execute the command
then execute
REMINDER: You edit thefileyousaveditas to what you saved the code as .
Now for a simple explanation:
The first argument
is the file that will be outputted when it's done.
The second argument
would be the folder all lua files are in.
The third argument
would be a array of files that you want appended, make sure this is in CORRECT ORDER of with the files your combining.
last reminder: The output.lua file gets compressed so if there's a error, don't edit that file, edit the separate files included.
Code:
JavaScript:
const luamin = require('luamin');
const fs = require('fs');
exports.build = function(output, folder, files) {
var callback = 0;
if(fs.existsSync(`./${output}`)) {
fs.unlinkSync(`./${output}`);
}
files.forEach((name) => {
if(fs.existsSync(`./${folder}/${name}`)) {
callback++;
if(callback == files.length) {
let lua = fs.readFileSync(`./${folder}/${name}`);
fs.appendFileSync(`./${output}`, `${lua}\n`);
console.log(`Processed file ${name}`);
console.log('Done, now parsing.');
return finish(output);
}
let lua = fs.readFileSync(`./${folder}/${name}`);
fs.appendFileSync(`./${output}`, `${lua}\n`);
console.log(`Processed file ${name}`);
}
});
}
const finish = function(output) {
let lua = fs.readFileSync(`./${output}`);
let minifed = luamin.minify(lua.toString());
fs.writeFileSync(`./${output}`, minifed, {encoding: 'utf8', flag: 'w'});
return console.log('Finished and done parsing.');
}
Code:
npm install -g luamin
After that save the code I gave you, in your command prompt (or cmd/terminal) execute the command
Code:
node
JavaScript:
require('./thefileyousaveditas.js').build('output.lua', 'src', ['1.lua', '2.lua', '3.lua']);
Now for a simple explanation:
The first argument
Code:
output.lua
The second argument
Code:
src
The third argument
Code:
['1.lua', '2.lua', '3.lua']
last reminder: The output.lua file gets compressed so if there's a error, don't edit that file, edit the separate files included.
Last edited:
