From 625bf21c84837f8ab257f8cb7f9e1636752397cb Mon Sep 17 00:00:00 2001 From: yuni Date: Wed, 12 Jun 2024 00:57:55 +0200 Subject: [PATCH] continuously set/update chat variable `$$player_oxygen_seconds` --- src/chat.rs | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/chat.rs b/src/chat.rs index 3bd56d4..49db1b7 100644 --- a/src/chat.rs +++ b/src/chat.rs @@ -79,6 +79,7 @@ impl Plugin for ChatPlugin { handle_new_conversations.before(handle_chat_events), handle_chat_events.before(handle_chat_scripts), handle_chat_scripts, + update_chat_variables, ), ); app.add_event::(); @@ -939,3 +940,12 @@ pub fn handle_chat_scripts( } } } + +pub fn update_chat_variables( + mut vars: ResMut, + q_player: Query<&actor::Suit, With>, +) { + if let Ok(suit) = q_player.get_single() { + vars.set_in_scope("$", "player_oxygen_seconds", (suit.oxygen / nature::OXY_S).to_string()); + } +}