Add color_print crate and implement it into the Lua error handler

This commit is contained in:
unittensor 2024-01-22 13:48:30 -05:00
parent 88ad707f39
commit c530a3ebd8
3 changed files with 41 additions and 1 deletions

38
Cargo.lock generated
View File

@ -368,6 +368,27 @@ dependencies = [
"unicode-width",
]
[[package]]
name = "color-print"
version = "0.3.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7a858372ff14bab9b1b30ea504f2a4bc534582aee3e42ba2d41d2a7baba63d5d"
dependencies = [
"color-print-proc-macro",
]
[[package]]
name = "color-print-proc-macro"
version = "0.3.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "57e37866456a721d0a404439a1adae37a31be4e0055590d053dfe6981e05003f"
dependencies = [
"nom",
"proc-macro2",
"quote",
"syn 1.0.109",
]
[[package]]
name = "com"
version = "0.6.0"
@ -1029,6 +1050,12 @@ dependencies = [
"paste",
]
[[package]]
name = "minimal-lexical"
version = "0.2.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "68354c5c6bd36d73ff3feceb05efa59b6acb7626617f4962be322a825e61f79a"
[[package]]
name = "mlua"
version = "0.9.4"
@ -1117,6 +1144,16 @@ dependencies = [
"memoffset",
]
[[package]]
name = "nom"
version = "7.1.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d273983c5a657a70a3e8f2a01329822f3b8c8172b73826411a55751e404a0a4a"
dependencies = [
"memchr",
"minimal-lexical",
]
[[package]]
name = "num-traits"
version = "0.2.17"
@ -1703,6 +1740,7 @@ name = "strafe-client"
version = "0.9.0"
dependencies = [
"bytemuck",
"color-print",
"configparser",
"ddsfile",
"glam",

View File

@ -7,6 +7,7 @@ edition = "2021"
[dependencies]
bytemuck = { version = "1.13.1", features = ["derive"] }
color-print = "0.3.5"
configparser = "3.0.2"
ddsfile = "0.5.1"
glam = "0.24.1"

View File

@ -1,5 +1,6 @@
use mlua::{Lua as Luau, Result, Table};
use glam::{Vec2, Vec3, Vec4, Quat};
use color_print::cprintln;
const STRAFE_VERSION: &str = env!("CARGO_PKG_VERSION");
@ -216,7 +217,7 @@ impl Luavm for StrafeluaGlobals {
pub fn error_wrapper(execute_result: Result<()>) {
match execute_result {
Ok(t) => t,
Err(e) => println!("[StrafeLua ERROR]: {}", e),
Err(e) => cprintln!("[StrafeLua ERROR]: <red>{}</red>", e),
}
}