general mindustry schematic tools
Diffstat (limited to 'schem_image/msch.js')
-rw-r--r--schem_image/msch.js18
1 files changed, 18 insertions, 0 deletions
diff --git a/schem_image/msch.js b/schem_image/msch.js
new file mode 100644
index 0000000..bb165a8
--- /dev/null
+++ b/schem_image/msch.js
@@ -0,0 +1,18 @@
+import * as fs from 'fs'
+import {
+ Schematic
+} from 'mindustry-schematic-parser'
+
+const file = process.argv.slice(2)[0]
+const buffer = fs.readFileSync(file)
+const schematic = Schematic.decode(buffer)
+
+console.log(schematic.name)
+
+// save a preview of the schematic
+schematic
+ .render({
+ background: false // disable background
+ })
+ .then(nodeCanvas => nodeCanvas.toBuffer())
+ .then(buffer => fs.writeFileSync('/tmp/mindustry_schematics/image.png', buffer)) \ No newline at end of file