From 40a4920b120cff0fd6db7a1b61c4dab74a33053d Mon Sep 17 00:00:00 2001 From: Quaternions Date: Tue, 31 Dec 2024 03:59:54 -0800 Subject: [PATCH] fix example --- README.md | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index cf08a3d..918eba2 100644 --- a/README.md +++ b/README.md @@ -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 }