From 37e0505839a74e1791210116ceaba89349f79cff Mon Sep 17 00:00:00 2001 From: hut Date: Wed, 20 Mar 2024 06:36:55 +0100 Subject: [PATCH] streamline defs.txt --- src/defs.txt | 92 ++++++++++++---------------------------------------- src/world.rs | 30 +++++++++++++++++ 2 files changed, 51 insertions(+), 71 deletions(-) diff --git a/src/defs.txt b/src/defs.txt index 646efa1..7b01ddc 100644 --- a/src/defs.txt +++ b/src/defs.txt @@ -1,79 +1,29 @@ chat "hialien" name "Icarus" - - msg 2 "Requesting permission to communicate..." - label "INIT" + msg 2 "INIT" "hi" "Requesting permission to communicate..." lvl "info" - goto "b" - - msg 4 "Oh hey there!" - label "b" - goto "c" - choice 3 "Uhm... hi" - label "c" - goto "c1" - msg 8 "Didn't even notice you! Was playing some VR Game! What's up?" - label "c1" - goto "d" - - msg 8 "Didn't even notice you! Was playing some VR Game! What's up?" - label "c" - goto "d" - choice "3" "I'm good, how are you?" - label "d" - goto "imgood" - choice 3 "Uhm... where am I? I don't feel so good." - label "d" - goto "imbad" - - msg 3.5 "Not so chatty, huh? That's ok. See you around." - label "d" - goto "pizza" - - msg 2.5 "Make sure to check out the Pizza place." - label "pizza" - goto "disco" - choice 3 "Will do, bye!" - label "disco" - goto "disco1" - msg 0 "Disconnected." - label "disco1" - goto "EXIT" - - msg 0 "Disconnected." - label "disco" - goto "EXIT" - - msg 5.5 "Are you sure? Your suit is sending a distress call. But whatever you say, have fun!" - label "imgood" - goto "pizza" - - msg 5.5 "Yeah I can imagine, looks like your suit is leaking. Take care!" - label "imbad" - goto "pizza" + msg 4 "hi" "vr" "Oh hey there!" + choice 3 "vr" "vr1" "Uhm... hi" + msg 8 "vr1" "notsochatty" "Didn't even notice you! Was playing some VR Game! What's up?" + msg 8 "vr" "notsochatty" "Didn't even notice you! Was playing some VR Game! What's up?" + choice 3 "notsochatty" "imgood" "I'm good, how are you?" + msg 5.5 "imgood" "pizza" "Are you sure? Your suit is sending a distress call. But whatever you say, have fun!" + choice 3 "notsochatty" "imbad" "Uhm... where am I? I don't feel so good." + msg 5.5 "imbad" "pizza" "Yeah I can imagine, looks like your suit is leaking. Take care!" + msg 3.5 "notsochatty" "pizza" "Not so chatty, huh? That's ok. See you around." + msg 2.5 "pizza" "end" "Make sure to check out the Pizza place." + choice 3 "end" "end1" "Will do, bye!" + msg 0 "end1" "EXIT" "Disconnected." + msg 0 "end" "EXIT" "Disconnected." chat "pizzeria" name "Space Pizza™" - msg 2 "Requesting permission to communicate..." - label "INIT" + msg 2 "INIT" "hi" "Requesting permission to communicate..." lvl "info" - goto "b" - msg 5 "Welcome to Space Pizza™, best pizza all across the Jovian rings!" - label "b" - goto "c" - msg 10 "Would you like to order today's special Miracle Spacefungi? Freshly blended pizza smoothie ready for your space suit feeding tube!" - label "c" - goto "d" - choice 3 "Pizza... smoothie? I think I'll pass..." - label "d" - goto "yourloss" - msg 3 "Your loss, mate" - label "yourloss" - goto "end" - msg 10 "Hello? Is anyone there? Is this a prank?" - label "d" - goto "end" - msg 0 "Disconnected." - label "end" + msg 5 "hi" "order" "Welcome to Space Pizza™, best pizza all across the Jovian rings!" + msg 10 "order" "anyone" "Would you like to order today's special Miracle Spacefungi? Freshly blended pizza smoothie ready for your space suit feeding tube!" + choice 3 "anyone" "yourloss" "Pizza... smoothie? I think I'll pass..." + msg 3 "yourloss" "end" "Your loss, mate" + msg 10 "anyone" "end" "Hello? Is anyone there? Is this a prank?" + msg 0 "end" "EXIT" "Disconnected." lvl "info" - goto "EXIT" diff --git a/src/world.rs b/src/world.rs index 154bbd6..db148dc 100644 --- a/src/world.rs +++ b/src/world.rs @@ -449,6 +449,21 @@ pub fn load_defs( continue; } } + ["msg", sleep, label, goto, text] => { + debug!("Registering message (sleep={}): {}", sleep, text); + state.spawn_chatbranch(&mut commands); + if let Ok(sleep_float) = sleep.parse::() { + state.delay = sleep_float; + state.text = text.to_string(); + state.stores_item = true; + state.is_choice = false; + state.goto = goto.to_string(); + state.label = label.to_string(); + } else { + error!("The 'sleep' value for this message is not a float: {}", line); + continue; + } + } ["choice", sleep, text] => { debug!("Registering choice (sleep={}): {}", sleep, text); state.spawn_chatbranch(&mut commands); @@ -462,6 +477,21 @@ pub fn load_defs( continue; } } + ["choice", sleep, label, goto, text] => { + debug!("Registering choice (sleep={}): {}", sleep, text); + state.spawn_chatbranch(&mut commands); + if let Ok(sleep_float) = sleep.parse::() { + state.delay = sleep_float; + state.text = text.to_string(); + state.stores_item = true; + state.is_choice = true; + state.goto = goto.to_string(); + state.label = label.to_string(); + } else { + error!("The 'sleep' value for this message is not a float: {}", line); + continue; + } + } ["goto", label] => { debug!("Registering goto: {}", label); state.goto = label.to_string();