Function rlbot::init[][src]

pub fn init() -> Result<RLBot, Box<Error>>

Initializes RLBot and returns a ready-to-use RLBot object.

This function will inject the RLBot core DLL into Rocket League, and then load the interface DLL. It might sleep for some time while it waits for RLBot to fully initialize.

Panics

Only one RLBot instance may be created over the life of the application. If you call this function more than once, it will panic. If you lose the RLBot instance, well, you should keep better track of your things.

Example

let rlbot = rlbot::init()?;
rlbot.start_match(MatchSettings::simple_1v1("Hero", "Villain"))?;

let mut packets = rlbot.packeteer();

// Wait for the match to start. `packets.next_flatbuffer()` sleeps until the next
// packet is available, so this loop will not roast your CPU :)
while !packets.next()?.GameInfo.RoundActive {}

loop {
    let packet = packets.next_flatbuffer()?;
    let input_args: flat::PlayerInputArgs = Default::default();
    let mut builder = flatbuffers::FlatBufferBuilder::new_with_capacity(1024);
    let player_input = flat::PlayerInput::create(&mut builder, &input_args);
    builder.finish(player_input, None);
    rlbot.update_player_input_flatbuffer(builder.finished_data())?;
}

See examples/simple for a complete example.