diff --git a/README.md b/README.md index 3b17a83..19ab130 100644 --- a/README.md +++ b/README.md @@ -54,7 +54,7 @@ podman run \ --detach \ --name trade_bot \ --secret secrets.toml \ - -v ./config/:/root/config/ \ + --volume ./config/:/root/config/ \ --env CONFIG=/root/config/config.toml \ --env SECRETS=/run/secrets/secrets.toml \ --env RUST_LOG=trade_bot \ diff --git a/src/bot.rs b/src/bot.rs index 76dc582..aabd0b1 100644 --- a/src/bot.rs +++ b/src/bot.rs @@ -17,8 +17,12 @@ use tokio::runtime::Runtime; use vek::Quaternion; use veloren_client::{addr::ConnectionArgs, Client, Event as VelorenEvent, SiteInfoRich, WorldExt}; use veloren_common::{ + character::Character, clock::Clock, - comp::{invite::InviteKind, item::ItemDefinitionIdOwned, ChatType, ControllerInputs, Ori, Pos}, + comp::{ + invite::InviteKind, item::ItemDefinitionIdOwned, CharacterState, ChatType, + ControllerInputs, Health, Ori, Pos, + }, outcome::Outcome, time::DayPeriod, trade::{PendingTrade, TradeAction, TradeResult}, @@ -96,13 +100,22 @@ impl Bot { .id .ok_or("Failed to get character ID")?; - client.request_character( - character_id, - ViewDistances { - terrain: 4, - entity: 4, - }, - ); + // This loop waits and retries requesting the character in the case that the character has + // logged out to recently. + while client.position().is_none() { + client.request_character( + character_id, + ViewDistances { + terrain: 4, + entity: 4, + }, + ); + + client + .tick(ControllerInputs::default(), clock.dt()) + .map_err(|error| format!("{error:?}"))?; + clock.tick(); + } let now = Instant::now();