commit f58ffe3d56e5be4cd346c5519c67d63e43c31a4f Author: Hornwitser Date: Wed Dec 4 12:01:39 2019 +0100 Innital concept Innital draft for diffrent shaped science packs. diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..00e8cbc --- /dev/null +++ b/.gitignore @@ -0,0 +1,9 @@ +# Default build dir +/dist/ + +# Node.js files +/node_modules/ +package-lock.json + +# Blender backup files +*.blend[1-9] \ No newline at end of file diff --git a/build.js b/build.js new file mode 100644 index 0000000..99ba665 --- /dev/null +++ b/build.js @@ -0,0 +1,77 @@ +"use strict"; +const events = require("events"); +const fs = require("fs-extra"); +const JSZip = require("jszip"); +const klaw = require("klaw"); +const path = require("path"); +const yargs = require("yargs"); + + +async function main() { + const args = yargs + .scriptName("build") + .options({ + 'clean': { describe: "Remove previous builds", type: 'boolean', default: false }, + 'build': { describe: "Build mod", type: 'boolean', default: true }, + 'pack': { describe: "Pack into zip file", type: 'boolean', default: true }, + 'source-dir': { describe: "Path to mod source directory", nargs: 1, type: 'string', default: "src" }, + 'output-dir': { describe: "Path to output built mod", nargs: 1, type: 'string', default: "dist" }, + }) + .argv + ; + + let info = JSON.parse(await fs.readFile(path.join(args.sourceDir, "info.json"))); + + if (args.clean) { + let splitter = /^(.*)_(\d+\.\d+\.\d+)(\.zip)?$/ + for (let entry of await fs.readdir(args.outputDir)) { + let match = splitter.exec(entry); + if (match) { + let [, name, version] = match; + if (name === info.name) { + let modPath = path.join(args.outputDir, entry); + console.log(`Removing ${modPath}`); + await fs.remove(modPath); + } + } + } + } + + if (args.build) { + await fs.ensureDir(args.outputDir); + let modName = `${info.name}_${info.version}`; + + if (args.pack) { + let zip = new JSZip(); + let walker = klaw(args.sourceDir) + .on('data', item => { + if (item.stats.isFile()) { + // On Windows the path created uses backslashes as the directory sepparator + // but the zip file needs to use forward slashes. We can't use the posix + // version of relative here as it doesn't work with Windows style paths. + let basePath = path.relative(args.sourceDir, item.path).replace(/\\/g, "/"); + zip.file(path.posix.join(modName, basePath), fs.createReadStream(item.path)); + } + }); + await events.once(walker, 'end'); + + let modPath = path.join(args.outputDir, `${modName}.zip`); + console.log(`Writing ${modPath}`); + let writeStream = zip.generateNodeStream().pipe(fs.createWriteStream(modPath)); + await events.once(writeStream, 'finish'); + + } else { + let modDir = path.join(args.outputDir, modName); + if (await fs.exists(modDir)) { + console.log(`Removing existing build ${modDir}`); + await fs.remove(modDir); + } + console.log(`Building ${modDir}`); + await fs.copy(args.sourceDir, modDir); + } + } +} + +if (module === require.main) { + main().catch(err => { console.log(err) }); +} diff --git a/model.blend b/model.blend new file mode 100644 index 0000000..7554436 Binary files /dev/null and b/model.blend differ diff --git a/package.json b/package.json new file mode 100644 index 0000000..5be5746 --- /dev/null +++ b/package.json @@ -0,0 +1,14 @@ +{ + "name": "clusterioMod", + "repository": "https://github.com/Danielv123/factorioClusterioMod", + "license": "MIT", + "engines": { + "node": ">=10" + }, + "dependencies": { + "fs-extra": "^6.0.1", + "jszip": "^3.2.2", + "klaw": "^3.0.0", + "yargs": "^14.2.2" + } +} diff --git a/src/data.lua b/src/data.lua new file mode 100644 index 0000000..1a0477a --- /dev/null +++ b/src/data.lua @@ -0,0 +1,43 @@ +local items = { + ["automation-science-pack"] = { + icon_size = 256, + icon = "__cb-science__/graphics/red.png", + }, + ["logistic-science-pack"] = { + icon_size = 256, + icon = "__cb-science__/graphics/green.png", + }, + ["military-science-pack"] = { + icon_size = 256, + icon = "__cb-science__/graphics/black.png", + }, + ["chemical-science-pack"] = { + icon_size = 256, + icon = "__cb-science__/graphics/cyan.png", + }, + ["production-science-pack"] = { + icon_size = 256, + icon = "__cb-science__/graphics/purple.png", + }, + ["utility-science-pack"] = { + icon_size = 256, + icon = "__cb-science__/graphics/yellow.png", + }, + ["space-science-pack"] = { + icon_size = 256, + icon = "__cb-science__/graphics/white.png", + }, +} + +for name, definition in pairs(items) do + print(name) + for property, value in pairs(definition) do + if data.raw.technology[name] then + print("setting tech "..name.." property "..property) + data.raw.technology[name][property] = value + end + if data.raw.tool[name] then + data.raw.tool[name][property] = value + end + end +end \ No newline at end of file diff --git a/src/graphics/black.png b/src/graphics/black.png new file mode 100644 index 0000000..bc1363f Binary files /dev/null and b/src/graphics/black.png differ diff --git a/src/graphics/cyan.png b/src/graphics/cyan.png new file mode 100644 index 0000000..667abde Binary files /dev/null and b/src/graphics/cyan.png differ diff --git a/src/graphics/green.png b/src/graphics/green.png new file mode 100644 index 0000000..61ca553 Binary files /dev/null and b/src/graphics/green.png differ diff --git a/src/graphics/purple.png b/src/graphics/purple.png new file mode 100644 index 0000000..4c9d04b Binary files /dev/null and b/src/graphics/purple.png differ diff --git a/src/graphics/red.png b/src/graphics/red.png new file mode 100644 index 0000000..768324f Binary files /dev/null and b/src/graphics/red.png differ diff --git a/src/graphics/white.png b/src/graphics/white.png new file mode 100644 index 0000000..c132516 Binary files /dev/null and b/src/graphics/white.png differ diff --git a/src/graphics/yellow.png b/src/graphics/yellow.png new file mode 100644 index 0000000..ecaf59c Binary files /dev/null and b/src/graphics/yellow.png differ diff --git a/src/info.json b/src/info.json new file mode 100644 index 0000000..076b9a4 --- /dev/null +++ b/src/info.json @@ -0,0 +1,9 @@ +{ + "name": "cb-science", + "version": "0.1.0", + "title": "Colour Blind Science", + "author": "Hornwitser", + "contact": "Hornwitser#6431 on Discord", + "description": "Alternative icons for science packs", + "factorio_version": "0.17" +} \ No newline at end of file diff --git a/src/thumbnail.png b/src/thumbnail.png new file mode 100644 index 0000000..5adb06c Binary files /dev/null and b/src/thumbnail.png differ