save game state about Luna's introduction

This commit is contained in:
yuni 2024-08-02 02:09:35 +02:00
parent 03be6d176c
commit 2337da40ae
3 changed files with 35 additions and 1 deletions

View file

@ -834,6 +834,7 @@ pub fn handle_chat_scripts(
mut ew_sfx: EventWriter<audio::PlaySfxEvent>,
mut ew_effect: EventWriter<visual::SpawnEffectEvent>,
mut ew_achievement: EventWriter<game::AchievementEvent>,
mut prefs: ResMut<var::Preferences>,
id2pos: Res<game::Id2Pos>,
id2v: Res<game::Id2V>,
) {
@ -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<var::GameVars>,
q_player: Query<&actor::Suit, With<actor::Player>>,
prefs: ResMut<var::Preferences>,
) {
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(),
);
}
}

View file

@ -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!

View file

@ -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<String>,
}