implement a second optional chat script parameter

This commit is contained in:
yuni 2024-03-23 20:49:48 +01:00
parent 36b6e3696c
commit bfa6a463d3
2 changed files with 10 additions and 0 deletions

View file

@ -84,6 +84,7 @@ pub struct ChatBranch {
pub choice: String, pub choice: String,
pub script: String, pub script: String,
pub script_parameter: String, pub script_parameter: String,
pub script_parameter2: String,
} }
#[derive(Component)] #[derive(Component)]

View file

@ -256,6 +256,7 @@ struct ParserState {
stores_item: bool, stores_item: bool,
script: String, script: String,
script_parameter: String, script_parameter: String,
script_parameter2: String,
} }
impl Default for ParserState { impl Default for ParserState {
fn default() -> Self { fn default() -> Self {
@ -290,6 +291,7 @@ impl Default for ParserState {
stores_item: false, stores_item: false,
script: "".to_string(), script: "".to_string(),
script_parameter: "".to_string(), script_parameter: "".to_string(),
script_parameter2: "".to_string(),
} }
} }
} }
@ -324,6 +326,7 @@ impl ParserState {
goto: self.goto.clone(), goto: self.goto.clone(),
script: self.script.clone(), script: self.script.clone(),
script_parameter: self.script_parameter.clone(), script_parameter: self.script_parameter.clone(),
script_parameter2: self.script_parameter2.clone(),
} }
} }
fn spawn_chat(&mut self, commands: &mut Commands) { fn spawn_chat(&mut self, commands: &mut Commands) {
@ -615,6 +618,12 @@ pub fn load_defs(
["script", scriptname, parameter] => { ["script", scriptname, parameter] => {
state.script = scriptname.to_string(); state.script = scriptname.to_string();
state.script_parameter = parameter.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(",")); error!("No match for [{}]", parts.join(","));