From Japanese mahjong wiki
(Redirected from Manual:MahjongTile)
Jump to: navigation, search

MahjongTile is a MediaWiki extension that makes it easy to output sequences of mahjong tile images, for example:

Tile-1m.pngTile-9m.pngTile-1p.pngTile-9p.pngTile-1s.pngTile-9s.pngTile-1z.pngTile-2z.pngTile-3z.pngTile-4z.png Tile-unknown.pngTile-unknown.pngTile-unknown.png

by use of the parser function #mjt. Specifically, it converts tile strings into their corresponding sequence of wiki markup image insertions, e.g.:

19p -> [[File:Tile-1p.png]][[File:Tile-9p.png]]
MahjongTile is written by bps. Bug reports and feature requests are always welcome.
The current version is 1.1.



The command can be invoked at any point in the wiki markup.


{{ #mjt: tile string | size option }}

Tile string

The tile string is similar to the way people communicate strings of tiles through text. First, an example, and its output:

Code Result
{{#mjt: 123m}}

The 123 part is self-explanatory, and the m part stands for man. 123m is called the tile string.

In general, a tile sequence consists of a series of digits (0 through 9) followed by a descriptor character describing which set they belong to. There are four groups:

Group Descriptor Full array (code) Full array
Man m
{{#mjt: 0123456789m}}
Pin p
{{#mjt: 0123456789p}}
Sou s
{{#mjt: 0123456789s}}
Jihai z
{{#mjt: 0123456789z}}
Paifu x
{{#mjt: 0123456789x}}

More complex configurations can also be described, by simply concatenating strings like above. Another example:

Code Result
{{#mjt: 456m789s}}

Spaces in a tile string are also ignored, so the following are equivalent:

123m 1111z
123m     1111z
1 23m1111z
123m11 11z
12 3m1111    z
1 23  m1 11 1z

The jihai group (see the table above) can also be used to refer to "unknown" or "face-down" tiles, as is often convenient when describing certain components of a hand. There is also a "blank" tile image (Tile-whitespace.png) with the same dimensions as an ordinary tile, in case something like that is ever needed. Examples:

Code Result
The iipeikou yaku looks something like:

{{#mjt: 345345m00000000z}}
The iipeikou yaku looks something like:


''Quiz''. What is the unknown tile in the following chii group?

{{#mjt: 13m9z'}}

''Answer''. {{#mjt: 2m}}
Quiz. What is the unknown tile in the following chii group?


Answer. Tile-2m.png

Tile orientation and stacking

There are additional flags that can be applied to specific tiles or entire tile groupings that adjust their orientation, or stack them up (for kan groups).

Orientation Flag
Sideways (pointing east/right) '
Stacked (pointing west/left) "

These can be applied after a digit, affecting that individual tile only, or after a descriptor, then affecting the entire sequence of tiles in that grouping. The following examples should make this clear:

Code Result Comment
{{#mjt: 123m 888p 333z 22z}} {{ #mjt: 11"1p }}
Tile-1m.pngTile-2m.pngTile-3m.pngTile-8p.pngTile-8p.pngTile-8p.pngTile-3z.pngTile-3z.pngTile-3z.pngTile-2z.pngTile-2z.png Tile-1p.pngTile-1p-k.pngTile-1p.png A simple winning hand involving a kan of 1-pin.
{{#mjt: 444m22p123678s}} {{#mjt: 111'z}}
Tile-4m.pngTile-4m.pngTile-4m.pngTile-2p.pngTile-2p.pngTile-1s.pngTile-2s.pngTile-3s.pngTile-6s.pngTile-7s.pngTile-8s.png Tile-1z.pngTile-1z.pngTile-1z-e.png This more realistic example demonstrates how the feature might actually be used. Note the two commands separated by a space, for readability.
{{#mjt: 1"33s'}} {{#mjt: 37'7s"}}
Tile-1s-k.pngTile-3s-e.pngTile-3s-e.png Tile-3s-k.pngTile-7s-e.pngTile-7s-k.png Here we see how the individually set orientation overrides the grouping orientation. This is just how it works, it's not indended for any magical purpose. It is probably more efficient.

If you can think of a reason why upside down tiles should also be implemented, let me know and I will add that too. I really can't think of a (not incredibly contrived) situation that warrants upside down tile images.

Note. The old behaviour (before 2015-01-25) of the " flag was to make the tile point west/left. This was totally useless though, so it has been replaced with the above configuration.

Arrows and paifu

The x descriptor offers a number of images that may be useful in construction of paifu. Note in particular that the height of the left- and right-arrows is equal to the usual height of an upright tile, so as to achieve proper centering. The mnemonic for remembering the arrow numbers is to start from zero, and count "up, down, left, right". I think this is the most natural way to enumerate the directions, at least in spoken English.

Size option

This is the size option you would pass to any image. First, an explanation with a regular image:

Code Result
13 red x.png

Now, try with MahjongTile:

Code Result
{{#mjt: 1m1s' | 200px}}

It works a bit weird, so you should refer to the MediaWiki help page. You may find you have to split up your sequence into multiple commands. If they are not separated by any whitespace, they should behave as if they were stuck together with just one command.

Reserved tiles

Should you use a tile which has not been described above, you will get a tile like this instead: Tile-reserved.png. In particular, the '- or "-modified x (paifu group) tiles will give you this at the moment (version 1.1). The purpose of this aggressive output is to avoid use of codes which may in future have some other meaning.

Potential new features

You are always welcome to make suggestions for what could be added.

  • Implement some neat way of displaying score sticks.



  • 89z changed to whitespace and question mark tiles respectively.
  • " flag changed from west-pointing sideways tiles to east-pointing stacked tiles (for kan groups).
  • z descriptor added, principally for paifu. Only the unflagged tiles have been given assignments. The remainder output a reserved tile image to warn editors if used mistakenly.
  • Parser now adds the baseline argument to the image code, for aesthetic qualities when formatting mentsu.
    • It would be nice to scan the wiki (automatically?) and update any previous cases where the sideways tiles were formatted in a centered position. This is necessary because updates to the extension do not automatically materialise in existing pages - they must be edited for changes to take effect.


Initial version.

Full list of tile images available