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