omt 0.7.2-alpha

A set of tiny tools mostly used for game development. A Texture atlas packer, a font converter, a pakfile creator.
Documentation
use std::fs;

use rlua::Lua;

pub struct Script {}

impl Script {
	pub fn build(input: &str, _mode: &str, output: &str) -> anyhow::Result<u32> {
		let data = match fs::read_to_string(input) {
			Ok(data) => data,
			Err(e) => anyhow::bail!(e),
		};

		let lua = Lua::new();

		let r = lua.context(|lua_ctx| match lua_ctx.load(&data).into_function() {
			Ok(_) => Ok(0),
			Err(e) => Err(e),
		});

		//		println!( "{:?}", r );

		match r {
			Ok(_f) => {
				println!("Writing lua to {}", output);
				fs::write(output, data).expect("// Unable to write file");
				return Ok(1);
			},
			Err(_e) => {
				anyhow::bail!("Error in script");
			},
		};
	}
}