From 2337da40ae03fb488f5445b532f5d842226a59d5 Mon Sep 17 00:00:00 2001 From: yuni Date: Fri, 2 Aug 2024 02:09:35 +0200 Subject: [PATCH] save game state about Luna's introduction --- src/chat.rs | 11 +++++++++++ src/chats/serenity.yaml | 22 +++++++++++++++++++++- src/var.rs | 3 +++ 3 files changed, 35 insertions(+), 1 deletion(-) diff --git a/src/chat.rs b/src/chat.rs index 0bd53ca..12428d4 100644 --- a/src/chat.rs +++ b/src/chat.rs @@ -834,6 +834,7 @@ pub fn handle_chat_scripts( mut ew_sfx: EventWriter, mut ew_effect: EventWriter, mut ew_achievement: EventWriter, + mut prefs: ResMut, id2pos: Res, id2v: Res, ) { @@ -941,6 +942,10 @@ pub fn handle_chat_scripts( "drinkpizza" => { ew_achievement.send(game::AchievementEvent::DrinkPizza); } + "save_state_luna_intro" => { + prefs.state_luna_intro = true; + prefs.save(); + } _ => { error!("Error, undefined chat script {name}"); } @@ -951,6 +956,7 @@ pub fn handle_chat_scripts( pub fn update_chat_variables( mut vars: ResMut, q_player: Query<&actor::Suit, With>, + prefs: ResMut, ) { if let Ok(suit) = q_player.get_single() { vars.set_in_scope( @@ -963,5 +969,10 @@ pub fn update_chat_variables( "player_suit_health_percent", ((suit.integrity * 100.0).round() as u8).to_string(), ); + vars.set_in_scope( + "$", + "state_luna_intro", + if prefs.state_luna_intro { 1 } else { 0 }.to_string(), + ); } } diff --git a/src/chats/serenity.yaml b/src/chats/serenity.yaml index 09fc699..73ce2e6 100644 --- a/src/chats/serenity.yaml +++ b/src/chats/serenity.yaml @@ -364,6 +364,24 @@ - No problem at all! - set: grateful 0 - goto: mainnode +- if: "$$state_luna_intro" + Outer Woods: + - if $explained: + - ... + - Yes, Outer Woods. + - At some point in my life, I made up various phrases which I can tell someone who claims to be able to travel back in time. + - The idea is, if someone will ever tell me one of those phrase *before* I tell them, it proves their time travel story. + - But... You're telling me the phrase *after* I told you. + - So you are proving nothing. + - Go kill yourself, show me how you magically wake up, and *then* tell me the phrase. + - goto: mainnode + - if ~$explained: + - Wh... + - How? + - YOU'RE AN ACTUAL TIME TRAVELER! + - Ok, I believe you now. + - My script is not finished though, so I won't do anything about it. *shrug* + - goto: mainnode - What are you up to?: - I'm running a workshop. Come by if you need any repairs! - Tinkering on various projects. @@ -458,7 +476,7 @@ - I just want to get away. From all this insanity, triviality, stupor... - Just want to create, without anyone standing in my way. - goto: mainnode -- if: $timetravel +- if: "$timetravel" Do you think time travel into the past is possible?: - No. - Well, theoretically, there's all sorts of way to do this but none of them are feasible. @@ -474,6 +492,8 @@ - Fascinating. - I don't believe you. - But there is obviously one way we can easily validate this. + - set: $explained + - script: save_state_luna_intro - "Kill yourself. Then come back to me, and make the first thing you say to me: Outer Woods." - That's genius.: - Thank you! diff --git a/src/var.rs b/src/var.rs index f9c3578..edab738 100644 --- a/src/var.rs +++ b/src/var.rs @@ -455,6 +455,9 @@ pub struct Preferences { pub shadows_sun: bool, pub avatar: usize, + // permanent game state + pub state_luna_intro: bool, + #[serde(skip)] pub source_file: Option, }