diff --git a/examples/basic.rs b/examples/basic.rs index 3f0768b..1b53886 100644 --- a/examples/basic.rs +++ b/examples/basic.rs @@ -6,16 +6,23 @@ use shulkerbox::{ }; fn main() { + // create a new datapack let mut dp = Datapack::new(16).with_supported_formats(16..=20); + + // get the namespace "test" let namespace = dp.namespace_mut("test"); + // get the function "foo" of the namespace "test" and add some commands let foo_function = namespace.function_mut("foo"); foo_function.add_command("say Hello, world!"); foo_function.add_command(Command::Debug("debug message".into())); + // get a call command to the function "foo" let call_func = Command::from(foo_function); let bar_function = namespace.function_mut("bar"); + // add the call command to the function "bar" bar_function.add_command(call_func); + // add a complex command to the function "bar" bar_function.add_command(Command::Execute(Execute::As( "@a".to_string(), Box::new(Execute::If( @@ -27,9 +34,12 @@ fn main() { )), ))); + // get the main function of the namespace "test" and add a command namespace.get_main_function_mut().add_command("say tick"); + // compile the datapack let v_folder = dp.compile(&CompileOptions::default()); + // place the compiled datapack in the "./dist" folder v_folder.place(Path::new("./dist")).unwrap(); }