snozbot / fungus

An easy to use Unity 3D library for creating illustrated Interactive Fiction games and more.
MIT License
1.63k stars 290 forks source link

Text in Square brackets in Say Dialogs being parsed out due to Ink support #963

Closed anta88 closed 3 years ago

anta88 commented 3 years ago

Describe the bug When a Say command contains a text wrapped into square brackets, that portion of text (including the brackets) is parsed out and not rendered ingame. This happens due to the changes to Fungus to support Ink variable text. The responsible script is Fungus/Scripts/Utils/TextVariationHandler.cs, method TokenizeVarySections.

To Reproduce

  1. Go to the scene 'TheExperiment' in the FungusExample 'Sherlock'
  2. Open the flowchart window, select the START block, select the first Say command
  3. Replace the text 'THE EXPERIMENT' with the text 'THE [test] EXPERIMENT'
  4. Play the game
  5. When that command is executed, you expect to read'THE [test] EXPERIMENT', instead you will read 'THE EXPERIMENT'

Expected behavior I understand this behavior is working as intended, but maybe it's possible somehow to restore the possibility of displaying text wrapped into square brackets. In my understanding, the variable text has into the brackets other special characters in order to control its behavior (|, &, !, ~). A possible solution would be for the code to check for any of these characters inside the square brackets. If there's none, then it means it's not a variable text and so it should be rendered as it is. Another option is to treat square brackets (and other characters as well) as special characters, and provide an escape mechanism. Or something like HTML special chars, whereas the string [ would be rendered as a left square bracket and the character [ would be considered a special character to be parsed.

Screenshots sherlock_brackets

Versions & Platform (please complete the following information):