From bfa6a463d3fd366aa03aa09b8c9e242400127ae4 Mon Sep 17 00:00:00 2001 From: hut Date: Sat, 23 Mar 2024 20:49:48 +0100 Subject: [PATCH] implement a second optional chat script parameter --- src/actor.rs | 1 + src/world.rs | 9 +++++++++ 2 files changed, 10 insertions(+) diff --git a/src/actor.rs b/src/actor.rs index a601eaf..7daa8a9 100644 --- a/src/actor.rs +++ b/src/actor.rs @@ -84,6 +84,7 @@ pub struct ChatBranch { pub choice: String, pub script: String, pub script_parameter: String, + pub script_parameter2: String, } #[derive(Component)] diff --git a/src/world.rs b/src/world.rs index 602d32e..f17a6d8 100644 --- a/src/world.rs +++ b/src/world.rs @@ -256,6 +256,7 @@ struct ParserState { stores_item: bool, script: String, script_parameter: String, + script_parameter2: String, } impl Default for ParserState { fn default() -> Self { @@ -290,6 +291,7 @@ impl Default for ParserState { stores_item: false, script: "".to_string(), script_parameter: "".to_string(), + script_parameter2: "".to_string(), } } } @@ -324,6 +326,7 @@ impl ParserState { goto: self.goto.clone(), script: self.script.clone(), script_parameter: self.script_parameter.clone(), + script_parameter2: self.script_parameter2.clone(), } } fn spawn_chat(&mut self, commands: &mut Commands) { @@ -615,6 +618,12 @@ pub fn load_defs( ["script", scriptname, parameter] => { state.script = scriptname.to_string(); state.script_parameter = parameter.to_string(); + state.script_parameter2 = "".to_string(); + } + ["script", scriptname, parameter, parameter2] => { + state.script = scriptname.to_string(); + state.script_parameter = parameter.to_string(); + state.script_parameter2 = parameter2.to_string(); } _ => { error!("No match for [{}]", parts.join(","));