Skip to content

Instantly share code, notes, and snippets.

@madidier
Last active July 24, 2023 23:23
Show Gist options
  • Save madidier/d39adaddc80eeb54925c1c19d09234e7 to your computer and use it in GitHub Desktop.
Save madidier/d39adaddc80eeb54925c1c19d09234e7 to your computer and use it in GitHub Desktop.

Advanced Tunic-Helper

Just put the following somewhere in your document, it doesn't really matter where exactly as long as you keep only one copy around. A settings widget will appear in the rendered pane at the corresponding place. It contains additional explanations.

```settings
```

Better parts/masks explanation

Getting the detailed explanation of how masks work may slighly spoil you from the process of figuring out Tunic's dialect. There is however no major spoiler here and examples are fake. If you want to skip this explanation for now, please leave the "Glyph Masks" part of your settings empty to avoid confusion.

Copy-paste the following into the left pane:

A "glyph" here corresponds to what one would call a letter in english. Some languages, like french for instance also allow letters to be "decorated", as in "CAFÉ" where the E gets an "accent".

In the vocabulary used here, the E and the accent would be the two parts of a single glyph, the accented "É". As long as you are only writing, composing glyphs from parts is straighforward: simply superpose the "parts" one over another and you get the full glyph.

Things get a bit more complex when you want to go the other way around. Let's look at the letters O and Q and imagine you are deciphering them the same way you are currently deciphering Tunic's language. How do you know Q is its own part and not an O with some yet unknown accent attached to it ? This is where masks come into play.

A mask works by taking a glyph and removing anything that does not overlap with the mask. Or, in other words, it works by computing the intersection between a mask and the glyph under scrutiny. So, for the "CAFÉ" example, you'd need two masks: one for the naked letters and another for the accents. The first mask could be a black rectangle like this ▮ where the second mask would be another, smaller black rectangle that sits on top of the first.

The glyph masks use the same principle, except that instead of being black rectangles, they will look like tunic glyphs. Let's say that I have guessed that the following two masks are what I need: `A/` and `/A`.

With these masks, `Kg` will get decomposed into 1) `Ag` and 2) `KA`, in _that_ order because that's the order I defined my masks in. Note that this decomposition depends purely on the masks and is independent of how parts were defined.

Also, the way these two masks are defined makes it impossible to confuse `bA` with `KA`+`RA` since there is only one possible decomposition.

If you're curious and want to have a look at the code that decomposes tunic glyphs, it is [right there](https://github.com/madidier/tunic-helper/blob/c559db1a3f249792974bcf0c5dc570097981dea0/src/tunic/composition.js#L61-L87).


```settings
{
  "masks": [
    "A/",
    "/A"
  ],
  "parts": [
    {
      "glyph": "AL",
      "mnemonic": "a",
      "description": ""
    },
    {
      "glyph": "bA",
      "mnemonic": "o",
      "description": ""
    },
    {
      "glyph": "TA",
      "mnemonic": "x",
      "description": ""
    },
    {
      "glyph": "KA",
      "mnemonic": "p",
      "description": ""
    }
  ]
}
```
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment