Marker tag support for ASCII maps.
// Suppose you have a map of 3 rooms and want to place a X
// depending on the room the character's in
// Raw map: [ ]-[ ]-[ ]
var map = '[<x:1>]-[<x:2>]-[<x:3>]'
var marker = new MapMarker(map)
// No current room set
marker.render() // <== [ ]-[ ]-[ ]
marker.markId = 1
marker.render() // <== [X]-[ ]-[ ]
marker.markId = 2
marker.render() // <== [ ]-[X]-[ ]
marker.markId = 3
marker.render() // <== [ ]-[ ]-[X]The tag format follows the following signature:
<x:markId[?trueString[|falseString]]>
Where:
markIdis a number or string to match against the marker's markId. Can also be a boolean (see Special Values section).trueString(optional) is the string to render when the position matches. Default isX.falseString(optional) is the string to render when the position does not match. Default is a space.
Examples:
<x:123>- will render anXat that position if the marker'smarkIdequals123, otherwise renders an empty space.<x:123?You are here>- same as above, but rendersYou are hereat the position.<x:123?Yes|No>- rendersYesif position matches, andNootherwise.
> and | are special characters that are part of the tag structure.
If you want to render > in either trueString or falseString, or | in trueString only [1], double them up.
Examples:
<x:123?>>>- will render a single>if position matches.<x:123?||>- will render a single|if position matches.<x:123?|||>>>- will render a single|if position matches, and a single>if position does not match.
[1] Note: | in falseString does not need to be doubled up.
markId has two special values:
false- use this value to render onlyfalseStringvalues.- This is the equivalent of rendering a map without marks.
marker.markId = false
marker.render() // <== [ ]-[ ]-[ ]true- use this value to rendertrueStringvalues at all positions.- This is the equivalent of rendering a map with all marks visible, useful during map building.
marker.markId = true
marker.render() // <== [X]-[X]-[X]MIT