mindustry logic execution, map- and schematic- parsing and rendering
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
use mindus::data::DataRead;
use mindus::{build_registry, Renderable};
use mindus::{MapSerializer, Serializer};
use std::env::Args;

use super::print_err;
pub fn main(args: Args) {
    let reg = build_registry();
    let mut ms = MapSerializer(&reg);

    // process schematics from command line
    for curr in args {
        if let Ok(s) = std::fs::read(curr) {
            match ms.deserialize(&mut DataRead::new(&s)) {
                Err(e) => print_err!(e, "fail"),
                Ok(m) => {
                	let o = m.render();
                	if let Ok(v) = std::env::var("SAVE") {
                		if v == "1" {
                			o.save("x.png").unwrap();
                		}
                	}
                }
            }
        }
    }
}