From a0e8318cbc39be8b6d26b2fccaa59ceec858c0f2 Mon Sep 17 00:00:00 2001 From: raeleus Date: Fri, 4 Oct 2024 00:15:29 -0700 Subject: [PATCH] You may add flavor text to any hashtag by typing text after a line break after the hashtag. Resolves #40 --- Input.js | 12 +++++++++++- README.md | 8 +++++--- 2 files changed, 16 insertions(+), 4 deletions(-) diff --git a/Input.js b/Input.js index bdc71a2..7ae2e9c 100644 --- a/Input.js +++ b/Input.js @@ -84,6 +84,15 @@ const modifier = (text) => { state.characterName = getCharacterName(rawText) text = sanitizeText(text) + + var lineBreakIndex = text.indexOf("\n") + if (lineBreakIndex > -1) { + state.flavorText = text.substring(lineBreakIndex + 1) + if (!state.flavorText.startsWith(" ")) state.flavorText = " " + state.flavorText + text = text.substring(0, lineBreakIndex) + } else { + state.flavorText = null + } command = text.substring(text.search(/#/) + 1) var commandName = getCommandName(command).toLowerCase().replaceAll(/[^a-z0-9\s]*/gi, "") @@ -192,6 +201,8 @@ const modifier = (text) => { text = processCommandSynonyms(command, commandName, statNames, doFlipCommandAbility) } + if (state.flavorText != null) text += state.flavorText + return { text } } @@ -1371,7 +1382,6 @@ function doGoToLocation(command) { if (index != -1) { location = state.locations[index] var direction = pointDirection(state.x, state.y, location.x, location.y) - log(`direction:${direction}`) var args = rotate(state.x, state.y, state.x + parseInt(arg0), state.y, direction) arg0 = Math.round(args[0]) arg1 = Math.round(args[1]) diff --git a/README.md b/README.md index 4ddff9b..a6c21db 100644 --- a/README.md +++ b/README.md @@ -17,10 +17,12 @@ See the [user guide here](https://github.com/raeleus/Hashtag-DnD/wiki). Watch the [tutorial video](https://youtu.be/E5TYU7rDaBQ). v. 0.1.1 -* #note without parameters will store the last action text into the notes -* #goto specified with a distance and location name will take you partially toward the target +* `#note` without parameters will store the last action text into the notes +* `#goto` specified with a distance and location name will take you partially toward the target +* `#goto` allows you to travel by typing a location number instead of a name +* You may add flavor text to any hashtag by typing text after a line break after the hashtag (shift + enter on desktop). Thanks Xiron! * You may use commas in coordinates now -* The scenario keeps track of how many days have passed since the adventure has started. See #rest, #showday, #setday. +* The scenario keeps track of how many days have passed since the adventure has started. See `#rest`, `#showday`, `#setday`. * Minor bug fixes and improvements v. 0.1.0