fix example

This commit is contained in:
Quaternions 2024-12-31 03:59:54 -08:00
parent 8b976c8e7d
commit 40a4920b12

View File

@ -4,19 +4,22 @@ Roblox Bhop/Surf Bot File Format
## Example
```rust
use strafesnet_roblox_bot_file::File;
use strafesnet_roblox_bot_file::{File,TimedBlockId};
let file=std::fs::File::open("bot_file")?;
let input=std::io::BufReader::new(file);
let bot_file=File::new(input)?;
for &(time,block_id) in &bot_file.header.offline_blocks_timeline{
let block=bot_file.read_block(block_id)?;
let mut bot_file=File::new(input)?;
for &TimedBlockId{time,block_id} in &bot_file.header.offline_blocks_timeline{
// header is immutably borrowed
// while data is mutably borrowed
let block_info=bot_file.header.block_info(block_id)?;
let block=bot_file.data.read_block_info(block_info)?;
// offline blocks include the following event types:
// World, Gravity, Run, Camera, Setting
}
for &(time,block_id) in &bot_file.header.realtime_blocks_timeline{
let block=bot_file.read_block(block_id)?;
for &TimedBlockId{time,block_id} in &bot_file.header.realtime_blocks_timeline{
let block_info=bot_file.header.block_info(block_id)?;
let block=bot_file.data.read_block_info(block_info)?;
// realtime blocks include the following event types:
// Input, Output, Sound
}