unicode vertical bar or pipe character

Hello,

I recently beta tested a game with inline diagram maps that I really liked. It is written in punyinform. Trying to make it work in TADS/Adv3lite has been challenging but I am close.

One character that I want to use but isn’t working is the vertical bar or pipe for a north/south connector. I have tried \u007C, \124 and \x7C. I have also tried a lowercase ‘l’ as an alternate but if the player is using a serif font, it looks funny.

Also, the output works with the typographicalOutputFilter active or deactivated. I may be misunderstanding it’s purpose.

Any help is appreciated!

Below is what I have tried along with several variations. If I omit the pipe character line, the diagram looks pretty close to what I want. This is only a partial diagram. Desired result is attached (ignore the gray tab lines and git status). I also omitted the square brackets in the code.

#charset "UTF-8"

#include <tads.h>
#include "advlite.h"

//modifies the output filter
modify typographicalOutputFilter
isActive = true
activate() { isActive = true; }
deactivate() { isActive = nil; }
filterText(ostr, val) { return isActive ? inherited(ostr, val) : val; }
;

DefineIAction(Diagram)
    execAction(cmd)
    {
        //typographicalOutputFilter.deactivate();
"\t\t\t\t\t\t\t\t\t\tN\n";
"\t\t\t\t\t\t\t\tParents Room\n";
"\t\t\t\t\t\t\t\t\t\t\x7C\n"; <--- This is the vertical pipe \x7c or \u007C or \124
"\t\t\t\t\t\t\t\t\t\t\n";
"W\t\tBoys Room - - - - - - Hall - - - - - - - Girls Room\t\tE\n";
"\t\t\t\t\t\t\t\t\t\t\n";
"\t\t\t\t\t\t\t\t\t\t\n";
        //typographicalOutputFilter.activate();
    }
;

VerbRule(Diagram)
'diagram' 
: VerbProduction
action = Diagram
verbPhrase = 'diagram'

;

I once wrote an extension for doing this mapping automatically. I believe you need to use the typewriter font mode to get the everything to align properly: <tt>

You can check the source for inspiration:

Especially the file scalable-text-renderer t3cartographer/renderers/scalable-text-renderer.t at master · toerob/t3cartographer · GitHub

Which seems to be close to what you aim for.

3 Likes

The best way to handle this is to use the library function showPreformatted(lst) where lst is a list of the strings that make up your diagram, which should be output with a newline between each string in the list. For further details, see the article on Input and Output issues in the Adv3Lite Technical Manual.

For example:


local diag = [
    '+---   -----------',
    '|    *         +  \\',
    '|    *     |   |   \\',
    '+-------------------'    
  ];
 
showPreformatted(diag);
2 Likes

Thank you Tomas. I had actually attempted to use this a while back. It’s a bit over my head!

showPreformatted(); is working perfectly.

1 Like