From 8b9d7d4afa0d9a1d2dc766c2cd8f3e89f78913ad Mon Sep 17 00:00:00 2001 From: hut Date: Wed, 20 Mar 2024 21:38:25 +0100 Subject: [PATCH] allow minus/underscore in command names and single-word strings --- src/defs.txt | 6 +++--- src/world.rs | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/defs.txt b/src/defs.txt index 0a58722..6b9f328 100644 --- a/src/defs.txt +++ b/src/defs.txt @@ -13,7 +13,7 @@ actor -2300 10 0 pizzeria actor -50 0 0 suit name Icarus - chatid "hi_icarus" + chatid hi_icarus alive yes pronoun it @@ -25,11 +25,11 @@ actor -2265 10 0 suit actor 0 0 0 error -chat "error" +chat error name "ERROR" msg 0 "INIT" "EXIT" "Unspecified conversation ID" -chat "hi_icarus" +chat hi_icarus name "Icarus" msg 2 "INIT" "hi" "Requesting permission to communicate..." lvl "info" diff --git a/src/world.rs b/src/world.rs index 66bc2e4..747d125 100644 --- a/src/world.rs +++ b/src/world.rs @@ -361,8 +361,8 @@ pub fn load_defs( mut commands: Commands, asset_server: Res, ) { - let re1 = Regex::new(r"^\s*([a-z]+)\s+(.*)$").unwrap(); - let re2 = Regex::new("\"([^\"]*)\"|(-?[0-9]+(?:\\.[0-9]+)?)|([a-zA-Z][a-zA-Z0-9]*)").unwrap(); + let re1 = Regex::new(r"^\s*([a-z_-]+)\s+(.*)$").unwrap(); + let re2 = Regex::new("\"([^\"]*)\"|(-?[0-9]+(?:\\.[0-9]+)?)|([a-zA-Z_-][a-zA-Z0-9_-]*)").unwrap(); let defs_string = include_str!("defs.txt"); let mut lines = defs_string.lines(); let mut state = ParserState::default();