Compare commits
No commits in common. "a0a95fac4c192511bc4bca4d6ec038a1f9579fad" and "886a37ab41368cf091d4e1bfb118a6626982414a" have entirely different histories.
a0a95fac4c
...
886a37ab41
95
Cargo.lock
generated
95
Cargo.lock
generated
@ -51,12 +51,6 @@ dependencies = [
|
|||||||
"windows-sys",
|
"windows-sys",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "anyhow"
|
|
||||||
version = "1.0.89"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "86fdf8605db99b54d3cd748a44c6d04df638eb5dafb219b135d0149bd0db01f6"
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "arrayref"
|
name = "arrayref"
|
||||||
version = "0.3.9"
|
version = "0.3.9"
|
||||||
@ -234,12 +228,6 @@ dependencies = [
|
|||||||
"windows-targets",
|
"windows-targets",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "log"
|
|
||||||
version = "0.4.22"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "a7a70ba024b9dc04c27ea2f0c0548feb474ec5c54bba33a7f72f873a39d07b24"
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "luau0-src"
|
name = "luau0-src"
|
||||||
version = "0.10.3+luau640"
|
version = "0.10.3+luau640"
|
||||||
@ -249,25 +237,6 @@ dependencies = [
|
|||||||
"cc",
|
"cc",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "lz4"
|
|
||||||
version = "1.28.0"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "4d1febb2b4a79ddd1980eede06a8f7902197960aa0383ffcfdd62fe723036725"
|
|
||||||
dependencies = [
|
|
||||||
"lz4-sys",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "lz4-sys"
|
|
||||||
version = "1.11.1+lz4-1.10.0"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "6bd8c0d6c6ed0cd30b3652886bb8711dc4bb01d637a68105a3d5158039b418e6"
|
|
||||||
dependencies = [
|
|
||||||
"cc",
|
|
||||||
"libc",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "memchr"
|
name = "memchr"
|
||||||
version = "2.7.4"
|
version = "2.7.4"
|
||||||
@ -345,25 +314,6 @@ dependencies = [
|
|||||||
"unicode-ident",
|
"unicode-ident",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "profiling"
|
|
||||||
version = "1.0.15"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "43d84d1d7a6ac92673717f9f6d1518374ef257669c24ebc5ac25d5033828be58"
|
|
||||||
dependencies = [
|
|
||||||
"profiling-procmacros",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "profiling-procmacros"
|
|
||||||
version = "1.0.15"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "8021cf59c8ec9c432cfc2526ac6b8aa508ecaf29cd415f271b8406c1b851c3fd"
|
|
||||||
dependencies = [
|
|
||||||
"quote",
|
|
||||||
"syn",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "quote"
|
name = "quote"
|
||||||
version = "1.0.37"
|
version = "1.0.37"
|
||||||
@ -403,21 +353,6 @@ dependencies = [
|
|||||||
"getrandom",
|
"getrandom",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "rbx_binary"
|
|
||||||
version = "0.7.4"
|
|
||||||
source = "sparse+https://git.itzana.me/api/packages/strafesnet/cargo/"
|
|
||||||
checksum = "18b401155b93f7151217bf51e36bdfa7bddcaf5f0d26b563c9ac3b08a3701c27"
|
|
||||||
dependencies = [
|
|
||||||
"log",
|
|
||||||
"lz4",
|
|
||||||
"profiling",
|
|
||||||
"rbx_dom_weak",
|
|
||||||
"rbx_reflection",
|
|
||||||
"rbx_reflection_database",
|
|
||||||
"thiserror",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "rbx_dom_weak"
|
name = "rbx_dom_weak"
|
||||||
version = "2.9.0"
|
version = "2.9.0"
|
||||||
@ -466,20 +401,6 @@ dependencies = [
|
|||||||
"thiserror",
|
"thiserror",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "rbx_xml"
|
|
||||||
version = "0.13.3"
|
|
||||||
source = "sparse+https://git.itzana.me/api/packages/strafesnet/cargo/"
|
|
||||||
checksum = "d6d1a15f58a1e4b4f578abe6eb5e1461cb16eea82fb4a147d5995c9b79f08d1f"
|
|
||||||
dependencies = [
|
|
||||||
"base64",
|
|
||||||
"log",
|
|
||||||
"rbx_dom_weak",
|
|
||||||
"rbx_reflection",
|
|
||||||
"rbx_reflection_database",
|
|
||||||
"xml-rs",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "rmp"
|
name = "rmp"
|
||||||
version = "0.8.14"
|
version = "0.8.14"
|
||||||
@ -504,9 +425,9 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "roblox_emulator"
|
name = "roblox_emulator"
|
||||||
version = "0.3.2"
|
version = "0.3.1"
|
||||||
source = "sparse+https://git.itzana.me/api/packages/strafesnet/cargo/"
|
source = "sparse+https://git.itzana.me/api/packages/strafesnet/cargo/"
|
||||||
checksum = "f73c50802f947550642aaeb3da2993751c0e37024ac922dec99313068596321e"
|
checksum = "b58d7bb42d458984e629a012757474710fd0e429c2c824a2529574be5e7c2fd6"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"glam",
|
"glam",
|
||||||
"mlua",
|
"mlua",
|
||||||
@ -518,13 +439,9 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "roblox_emulator_cli"
|
name = "roblox_emulator_cli"
|
||||||
version = "0.1.2"
|
version = "0.1.1"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"anyhow",
|
|
||||||
"clap",
|
"clap",
|
||||||
"rbx_binary",
|
|
||||||
"rbx_dom_weak",
|
|
||||||
"rbx_xml",
|
|
||||||
"roblox_emulator",
|
"roblox_emulator",
|
||||||
]
|
]
|
||||||
|
|
||||||
@ -688,12 +605,6 @@ version = "0.52.6"
|
|||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "589f6da84c646204747d1270a2a5661ea66ed1cced2631d546fdfb155959f9ec"
|
checksum = "589f6da84c646204747d1270a2a5661ea66ed1cced2631d546fdfb155959f9ec"
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "xml-rs"
|
|
||||||
version = "0.8.22"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "af4e2e2f7cba5a093896c1e150fbfe177d1883e7448200efb81d40b9d339ef26"
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "zerocopy"
|
name = "zerocopy"
|
||||||
version = "0.7.35"
|
version = "0.7.35"
|
||||||
|
13
Cargo.toml
13
Cargo.toml
@ -1,6 +1,6 @@
|
|||||||
[package]
|
[package]
|
||||||
name = "roblox_emulator_cli"
|
name = "roblox_emulator_cli"
|
||||||
version = "0.1.2"
|
version = "0.1.1"
|
||||||
edition = "2021"
|
edition = "2021"
|
||||||
repository = "https://git.itzana.me/StrafesNET/roblox_emulator_cli"
|
repository = "https://git.itzana.me/StrafesNET/roblox_emulator_cli"
|
||||||
license = "MIT OR Apache-2.0"
|
license = "MIT OR Apache-2.0"
|
||||||
@ -8,14 +8,5 @@ description = "Use roblox_emulator from cli."
|
|||||||
authors = ["Rhys Lloyd <krakow20@gmail.com>"]
|
authors = ["Rhys Lloyd <krakow20@gmail.com>"]
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
anyhow = "1.0.89"
|
|
||||||
clap = { version = "4.5.18", features = ["derive"] }
|
clap = { version = "4.5.18", features = ["derive"] }
|
||||||
roblox_emulator = { version = "0.3.2", registry = "strafesnet" }
|
roblox_emulator = { version = "0.3.1", registry = "strafesnet" }
|
||||||
rbx_binary = { version = "0.7.4", registry = "strafesnet" }
|
|
||||||
rbx_dom_weak = { version = "2.9.0", registry = "strafesnet" }
|
|
||||||
rbx_xml = { version = "0.13.3", registry = "strafesnet" }
|
|
||||||
|
|
||||||
[profile.release]
|
|
||||||
#lto = true
|
|
||||||
strip = true
|
|
||||||
codegen-units = 1
|
|
||||||
|
83
src/main.rs
83
src/main.rs
@ -13,96 +13,31 @@ struct Cli{
|
|||||||
#[derive(Subcommand)]
|
#[derive(Subcommand)]
|
||||||
enum Commands {
|
enum Commands {
|
||||||
RunScript(RunScriptSubcommand),
|
RunScript(RunScriptSubcommand),
|
||||||
RunModel(RunModelSubcommand),
|
|
||||||
RunPlace(RunPlaceSubcommand),
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Args)]
|
#[derive(Args)]
|
||||||
struct RunScriptSubcommand {
|
struct RunScriptSubcommand {
|
||||||
#[arg()]
|
#[arg(long)]
|
||||||
input_file:PathBuf,
|
|
||||||
}
|
|
||||||
#[derive(Args)]
|
|
||||||
struct RunModelSubcommand{
|
|
||||||
#[arg()]
|
|
||||||
input_file:PathBuf,
|
|
||||||
}
|
|
||||||
#[derive(Args)]
|
|
||||||
struct RunPlaceSubcommand{
|
|
||||||
#[arg()]
|
|
||||||
input_file:PathBuf,
|
input_file:PathBuf,
|
||||||
}
|
}
|
||||||
|
|
||||||
fn main()->anyhow::Result<()>{
|
fn main(){
|
||||||
let cli=Cli::parse();
|
let cli=Cli::parse();
|
||||||
match cli.command{
|
match cli.command{
|
||||||
Commands::RunScript(command)=>run_script(command.input_file),
|
Commands::RunScript(command)=>run_script(command.input_file),
|
||||||
Commands::RunModel(command)=>run_model(command.input_file),
|
|
||||||
Commands::RunPlace(command)=>run_place(command.input_file),
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn run_script(input_file:PathBuf)->anyhow::Result<()>{
|
fn run_script(
|
||||||
|
input_file:PathBuf,
|
||||||
|
){//->Result<(),roblox_emulator::runner::Error>{
|
||||||
let source={
|
let source={
|
||||||
let mut source=String::new();
|
let mut source=String::new();
|
||||||
std::fs::File::open(input_file)?.read_to_string(&mut source)?;
|
std::fs::File::open(input_file).unwrap().read_to_string(&mut source).unwrap();
|
||||||
source
|
source
|
||||||
};
|
};
|
||||||
let (mut context,script,services)=roblox_emulator::context::Context::script_singleton(source);
|
let (mut context,script,services)=roblox_emulator::context::Context::script_singleton(source);
|
||||||
let runner=roblox_emulator::runner::Runner::new()?;
|
let runner=roblox_emulator::runner::Runner::new().unwrap();
|
||||||
let runnable=runner.runnable_context(&mut context,&services)?;
|
let runnable=runner.runnable_context(&mut context,&services).unwrap();
|
||||||
runnable.run_script(script)?;
|
runnable.run_script(script).unwrap();
|
||||||
Ok(())
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Debug)]
|
|
||||||
pub enum ReadError{
|
|
||||||
RbxBinary(rbx_binary::DecodeError),
|
|
||||||
RbxXml(rbx_xml::DecodeError),
|
|
||||||
Io(std::io::Error),
|
|
||||||
UnknownFileFormat,
|
|
||||||
}
|
|
||||||
impl std::fmt::Display for ReadError{
|
|
||||||
fn fmt(&self,f:&mut std::fmt::Formatter<'_>)->std::fmt::Result{
|
|
||||||
write!(f,"{self:?}")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
impl std::error::Error for ReadError{}
|
|
||||||
|
|
||||||
pub fn read<R:Read>(input:R)->Result<rbx_dom_weak::WeakDom,ReadError>{
|
|
||||||
let mut buf=std::io::BufReader::new(input);
|
|
||||||
let peek=std::io::BufRead::fill_buf(&mut buf).map_err(ReadError::Io)?;
|
|
||||||
match &peek[0..8]{
|
|
||||||
b"<roblox!"=>rbx_binary::from_reader(buf).map_err(ReadError::RbxBinary),
|
|
||||||
b"<roblox "=>rbx_xml::from_reader_default(buf).map_err(ReadError::RbxXml),
|
|
||||||
_=>Err(ReadError::UnknownFileFormat),
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
fn run_model(input_file:PathBuf)->anyhow::Result<()>{
|
|
||||||
let file=std::fs::File::open(input_file)?;
|
|
||||||
let dom=read(file)?;
|
|
||||||
let (dom,services)=roblox_emulator::place::new_place_with_instances_in_workspace(dom);
|
|
||||||
let mut context=roblox_emulator::context::Context::new(dom);
|
|
||||||
let scripts=context.scripts();
|
|
||||||
let runner=roblox_emulator::runner::Runner::new()?;
|
|
||||||
let runnable=runner.runnable_context(&mut context,&services)?;
|
|
||||||
for script in scripts{
|
|
||||||
runnable.run_script(script)?;
|
|
||||||
}
|
|
||||||
Ok(())
|
|
||||||
}
|
|
||||||
|
|
||||||
fn run_place(input_file:PathBuf)->anyhow::Result<()>{
|
|
||||||
let file=std::fs::File::open(input_file)?;
|
|
||||||
let dom=read(file)?;
|
|
||||||
let services=roblox_emulator::place::Services::find_in(&dom).ok_or(anyhow::Error::msg("Could not find Workspace"))?;
|
|
||||||
let mut context=roblox_emulator::context::Context::new(dom);
|
|
||||||
let scripts=context.scripts();
|
|
||||||
let runner=roblox_emulator::runner::Runner::new()?;
|
|
||||||
let runnable=runner.runnable_context(&mut context,&services)?;
|
|
||||||
for script in scripts{
|
|
||||||
runnable.run_script(script)?;
|
|
||||||
}
|
|
||||||
Ok(())
|
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user