write file correctly

This commit is contained in:
Quaternions 2024-01-24 16:58:46 -08:00
parent 56899fa7da
commit 046df78a86

@ -1542,6 +1542,11 @@ async fn compile(config:CompileConfig)->AResult<()>{
output_place.push("place.rbxl");
}
let output=std::io::BufWriter::new(std::fs::File::create(output_place)?);
rbx_binary::to_writer(output,&dom,&[dom.root_ref()])?;
//write workspace:GetChildren()[1]
let workspace_children=dom.root().children();
if workspace_children.len()!=1{
return Err(anyhow::Error::msg("there can only be one model"));
}
rbx_binary::to_writer(output, &dom, &[workspace_children[0]])?;
Ok(())
}