Add loop to wait for recently logged out characters
This commit is contained in:
parent
29e3178eba
commit
86a579714e
@ -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 \
|
||||
|
15
src/bot.rs
15
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,6 +100,9 @@ impl Bot {
|
||||
.id
|
||||
.ok_or("Failed to get character ID")?;
|
||||
|
||||
// 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 {
|
||||
@ -104,6 +111,12 @@ impl Bot {
|
||||
},
|
||||
);
|
||||
|
||||
client
|
||||
.tick(ControllerInputs::default(), clock.dt())
|
||||
.map_err(|error| format!("{error:?}"))?;
|
||||
clock.tick();
|
||||
}
|
||||
|
||||
let now = Instant::now();
|
||||
|
||||
Ok(Bot {
|
||||
|
Loading…
Reference in New Issue
Block a user