https://en.wikipedia.org/w/index.php?action=history&feed=atom&title=Module%3AShogi_diagram%2Fsandbox Module:Shogi diagram/sandbox - Revision history 2025-06-09T10:10:41Z Revision history for this page on the wiki MediaWiki 1.45.0-wmf.4 https://en.wikipedia.org/w/index.php?title=Module:Shogi_diagram/sandbox&diff=1101116234&oldid=prev Techie3: Undid revision 1101116102 by Techie3 (talk) 2022-07-29T11:19:59Z <p>Undid revision 1101116102 by <a href="/wiki/Special:Contributions/Techie3" title="Special:Contributions/Techie3">Techie3</a> (<a href="/wiki/User_talk:Techie3" title="User talk:Techie3">talk</a>)</p> <table style="background-color: #fff; color: #202122;" data-mw="interface"> <col class="diff-marker" /> <col class="diff-content" /> <col class="diff-marker" /> <col class="diff-content" /> <tr class="diff-title" lang="en"> <td colspan="2" style="background-color: #fff; color: #202122; text-align: center;">← Previous revision</td> <td colspan="2" style="background-color: #fff; color: #202122; text-align: center;">Revision as of 11:19, 29 July 2022</td> </tr><tr> <td colspan="2" class="diff-lineno">Line 248:</td> <td colspan="2" class="diff-lineno">Line 248:</td> </tr> <tr> <td class="diff-marker"></td> <td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div> </div></td> <td class="diff-marker"></td> <td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div> </div></td> </tr> <tr> <td class="diff-marker"></td> <td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div> -- iterate over the 81 shogi piece arguments (left to right, top to bottom)</div></td> <td class="diff-marker"></td> <td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div> -- iterate over the 81 shogi piece arguments (left to right, top to bottom)</div></td> </tr> <tr> <td class="diff-marker" data-marker="−"></td> <td style="color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;"><div> -- i couldn't figure out how to do this is in a clever loopy way as i couldn't figure out how to close the html tags</div></td> <td colspan="2" class="diff-empty diff-side-added"></td> </tr> <tr> <td class="diff-marker" data-marker="−"></td> <td style="color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;"><div> -- whatever, it's repetitive, but it works</div></td> <td colspan="2" class="diff-empty diff-side-added"></td> </tr> <tr> <td class="diff-marker"></td> <td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div> </div></td> <td class="diff-marker"></td> <td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div> </div></td> </tr> <tr> <td class="diff-marker"></td> <td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div> -- index number displacement/offset</div></td> <td class="diff-marker"></td> <td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div> -- index number displacement/offset</div></td> </tr> <tr> <td colspan="2" class="diff-lineno">Line 257:</td> <td colspan="2" class="diff-lineno">Line 255:</td> </tr> <tr> <td class="diff-marker"></td> <td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div> </div></td> <td class="diff-marker"></td> <td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div> </div></td> </tr> <tr> <td class="diff-marker"></td> <td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div> -- the row for the shogi pieces</div></td> <td class="diff-marker"></td> <td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div> -- the row for the shogi pieces</div></td> </tr> <tr> <td colspan="2" class="diff-empty diff-side-deleted"></td> <td class="diff-marker" data-marker="+"></td> <td style="color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;"><br /></td> </tr> <tr> <td class="diff-marker" data-marker="−"></td> <td style="color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;"><div> -- row 1</div></td> <td colspan="2" class="diff-empty diff-side-added"></td> </tr> <tr> <td class="diff-marker"></td> <td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div> for icols = 1,9 do</div></td> <td class="diff-marker"></td> <td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div> for icols = 1,9 do</div></td> </tr> <tr> <td class="diff-marker"></td> <td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div> local trow = shogitable:tag('tr')</div></td> <td class="diff-marker"></td> <td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div> local trow = shogitable:tag('tr')</div></td> </tr> <tr> <td colspan="2" class="diff-lineno">Line 263:</td> <td colspan="2" class="diff-lineno">Line 261:</td> </tr> <tr> <td class="diff-marker"></td> <td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div> -- put a single piece into a &lt;td&gt;</div></td> <td class="diff-marker"></td> <td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div> -- put a single piece into a &lt;td&gt;</div></td> </tr> <tr> <td class="diff-marker"></td> <td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div> -- iterate over 9 pieces in the row</div></td> <td class="diff-marker"></td> <td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div> -- iterate over 9 pieces in the row</div></td> </tr> <tr> <td class="diff-marker" data-marker="−"></td> <td style="color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;"><div> for irow = (icols*9)-8,(icols*9)<del style="font-weight: bold; text-decoration: none;">+1</del> do</div></td> <td class="diff-marker" data-marker="+"></td> <td style="color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;"><div> for irow = (icols*9)-8,(icols*9) do</div></td> </tr> <tr> <td class="diff-marker"></td> <td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div> trow:wikitext( makeTD(args[(irow+nx)]) )</div></td> <td class="diff-marker"></td> <td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div> trow:wikitext( makeTD(args[(irow+nx)]) )</div></td> </tr> <tr> <td class="diff-marker"></td> <td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div> end</div></td> <td class="diff-marker"></td> <td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div> end</div></td> </tr> </table> Techie3 https://en.wikipedia.org/w/index.php?title=Module:Shogi_diagram/sandbox&diff=1101116102&oldid=prev Techie3 at 11:18, 29 July 2022 2022-07-29T11:18:56Z <p></p> <table style="background-color: #fff; color: #202122;" data-mw="interface"> <col class="diff-marker" /> <col class="diff-content" /> <col class="diff-marker" /> <col class="diff-content" /> <tr class="diff-title" lang="en"> <td colspan="2" style="background-color: #fff; color: #202122; text-align: center;">← Previous revision</td> <td colspan="2" style="background-color: #fff; color: #202122; text-align: center;">Revision as of 11:18, 29 July 2022</td> </tr><tr> <td colspan="2" class="diff-lineno">Line 263:</td> <td colspan="2" class="diff-lineno">Line 263:</td> </tr> <tr> <td class="diff-marker"></td> <td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div> -- put a single piece into a &lt;td&gt;</div></td> <td class="diff-marker"></td> <td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div> -- put a single piece into a &lt;td&gt;</div></td> </tr> <tr> <td class="diff-marker"></td> <td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div> -- iterate over 9 pieces in the row</div></td> <td class="diff-marker"></td> <td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div> -- iterate over 9 pieces in the row</div></td> </tr> <tr> <td class="diff-marker" data-marker="−"></td> <td style="color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;"><div> for irow = (icols*9)-8,(icols*9) do</div></td> <td class="diff-marker" data-marker="+"></td> <td style="color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;"><div> for irow = (icols*9)-8,(icols*9)<ins style="font-weight: bold; text-decoration: none;">+1</ins> do</div></td> </tr> <tr> <td class="diff-marker"></td> <td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div> trow:wikitext( makeTD(args[(irow+nx)]) )</div></td> <td class="diff-marker"></td> <td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div> trow:wikitext( makeTD(args[(irow+nx)]) )</div></td> </tr> <tr> <td class="diff-marker"></td> <td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div> end</div></td> <td class="diff-marker"></td> <td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div> end</div></td> </tr> </table> Techie3 https://en.wikipedia.org/w/index.php?title=Module:Shogi_diagram/sandbox&diff=1101116002&oldid=prev Techie3 at 11:18, 29 July 2022 2022-07-29T11:18:09Z <p></p> <table style="background-color: #fff; color: #202122;" data-mw="interface"> <col class="diff-marker" /> <col class="diff-content" /> <col class="diff-marker" /> <col class="diff-content" /> <tr class="diff-title" lang="en"> <td colspan="2" style="background-color: #fff; color: #202122; text-align: center;">← Previous revision</td> <td colspan="2" style="background-color: #fff; color: #202122; text-align: center;">Revision as of 11:18, 29 July 2022</td> </tr><tr> <td colspan="2" class="diff-lineno">Line 258:</td> <td colspan="2" class="diff-lineno">Line 258:</td> </tr> <tr> <td class="diff-marker"></td> <td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div> -- the row for the shogi pieces</div></td> <td class="diff-marker"></td> <td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div> -- the row for the shogi pieces</div></td> </tr> <tr> <td class="diff-marker"></td> <td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div> -- row 1</div></td> <td class="diff-marker"></td> <td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div> -- row 1</div></td> </tr> <tr> <td class="diff-marker" data-marker="−"></td> <td style="color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;"><div> for icols = <del style="font-weight: bold; text-decoration: none;">0</del>,<del style="font-weight: bold; text-decoration: none;">8</del> do</div></td> <td class="diff-marker" data-marker="+"></td> <td style="color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;"><div> for icols = <ins style="font-weight: bold; text-decoration: none;">1</ins>,<ins style="font-weight: bold; text-decoration: none;">9</ins> do</div></td> </tr> <tr> <td class="diff-marker"></td> <td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div> local trow = shogitable:tag('tr')</div></td> <td class="diff-marker"></td> <td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div> local trow = shogitable:tag('tr')</div></td> </tr> <tr> <td class="diff-marker"></td> <td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div> :css('font-size', piecefontsize)</div></td> <td class="diff-marker"></td> <td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div> :css('font-size', piecefontsize)</div></td> </tr> <tr> <td class="diff-marker"></td> <td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div> -- put a single piece into a &lt;td&gt;</div></td> <td class="diff-marker"></td> <td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div> -- put a single piece into a &lt;td&gt;</div></td> </tr> <tr> <td class="diff-marker"></td> <td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div> -- iterate over 9 pieces in the row</div></td> <td class="diff-marker"></td> <td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div> -- iterate over 9 pieces in the row</div></td> </tr> <tr> <td colspan="2" class="diff-empty diff-side-deleted"></td> <td class="diff-marker"><a class="mw-diff-movedpara-right" title="Paragraph was moved. Click to jump to old location." href="#movedpara_5_0_lhs">&#x26AB;</a></td> <td style="color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;"><div><a name="movedpara_3_0_rhs"></a> for irow = (icols*9)<ins style="font-weight: bold; text-decoration: none;">-8</ins>,(icols*9) do</div></td> </tr> <tr> <td class="diff-marker" data-marker="−"></td> <td style="color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;"><div> </div></td> <td colspan="2" class="diff-empty diff-side-added"></td> </tr> <tr> <td class="diff-marker"><a class="mw-diff-movedpara-left" title="Paragraph was moved. Click to jump to new location." href="#movedpara_3_0_rhs">&#x26AB;</a></td> <td style="color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;"><div><a name="movedpara_5_0_lhs"></a> for irow = (icols*9)<del style="font-weight: bold; text-decoration: none;">+1</del>,<del style="font-weight: bold; text-decoration: none;">(</del>(icols<del style="font-weight: bold; text-decoration: none;">+1)</del>*9) do</div></td> <td colspan="2" class="diff-empty diff-side-added"></td> </tr> <tr> <td class="diff-marker"></td> <td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div> trow:wikitext( makeTD(args[(irow+nx)]) )</div></td> <td class="diff-marker"></td> <td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div> trow:wikitext( makeTD(args[(irow+nx)]) )</div></td> </tr> <tr> <td class="diff-marker"></td> <td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div> end</div></td> <td class="diff-marker"></td> <td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div> end</div></td> </tr> </table> Techie3 https://en.wikipedia.org/w/index.php?title=Module:Shogi_diagram/sandbox&diff=1101114470&oldid=prev Techie3: Test 2022-07-29T11:05:49Z <p>Test</p> <p><b>New page</b></p><div>local shogiobject = {}<br /> <br /> -----------------------<br /> -- internal functions <br /> -----------------------<br /> <br /> <br /> -- returns a japanese character for a roman letter abbreviation<br /> -- called by the shogiboard() function<br /> local function piecesymbol(abbreviation)<br /> -- the abbreviation argument is a string of 1-3 letters that stand for the English names of the shogi pieces<br /> -- the abbreviation is extracted out of a longer string by the processString() function<br /> <br /> -- letter to character mapping (hash table)<br /> local piecenames = {<br /> p = &#039;歩&#039;,<br /> t = &#039;と&#039;,<br /> l = &#039;香&#039;,<br /> pl = &#039;杏&#039;,<br /> n = &#039;桂&#039;,<br /> pn = &#039;圭&#039;,<br /> s = &#039;銀&#039;,<br /> ps = &#039;全&#039;,<br /> g = &#039;金&#039;,<br /> b = &#039;角&#039;,<br /> h = &#039;馬&#039;,<br /> r = &#039;飛&#039;,<br /> d = &#039;龍&#039;,<br /> gyoku = &#039;玉&#039;,<br /> ou = &#039;王&#039;,<br /> tx = &#039;个&#039;,<br /> plx = &#039;仝&#039;,<br /> pnx = &#039;今&#039;,<br /> dx = &#039;竜&#039;,<br /> e = &#039;象&#039;,<br /> a = &#039;太&#039;<br /> }<br /> -- spit out the character corresponding to abbreviation<br /> -- if the abbreviation string is empty, then spit out nobreak space (for html tables) <br /> piece = piecenames[abbreviation] or &#039;&amp;nbsp;&#039;<br /> return string.format( piece )<br /> end<br /> <br /> <br /> -- function separates out the piece, the side, and the boldness info present in the string argument<br /> -- it returns an array with these three values plus the color (for promoted pieces)<br /> -- this info is passed to the makeTD() function<br /> function processString(ss)<br /> -- strip whitespace<br /> ss = mw.text.trim(ss)<br /> <br /> -- get the last character of the string<br /> local lastchar = mw.ustring.sub(ss, -1)<br /> <br /> -- chop off last character of string<br /> local restofstring = mw.ustring.sub(ss, 1, -2)<br /> <br /> -- default is normal font<br /> -- but if the string ends with &#039;l&#039; for &#039;last move&#039;, <br /> -- then the font should be bold and we need to get a new string with the this &#039;l&#039; chopped off (with a new last character)<br /> local boldness = &#039;normal&#039;<br /> if lastchar:match(&#039;l&#039;) then<br /> boldness = &#039;bold&#039;<br /> lastchar = mw.ustring.sub(restofstring, -1)<br /> restofstring = mw.ustring.sub(restofstring, 1, -2)<br /> end<br /> <br /> -- the side is either &#039;g&#039; for &#039;gote&#039; or &#039;s&#039; for &#039;sente&#039;<br /> -- it&#039;s the last character in the string (and if the string ended)<br /> local side = lastchar<br /> <br /> -- the leftover string is the shogi piece abbreviation<br /> local pieceabbr = restofstring<br /> <br /> -- default is black font<br /> -- if the piece is promoted (one the abbreviations below), then the piece should be red<br /> local color = &#039;black&#039;<br /> if pieceabbr:match(&#039;t&#039;) or pieceabbr:match(&#039;pl&#039;) or pieceabbr:match(&#039;pn&#039;) or pieceabbr:match(&#039;ps&#039;) or pieceabbr:match(&#039;h&#039;) or pieceabbr:match(&#039;d&#039;) then<br /> color = &#039;red&#039;<br /> end<br /> -- this is an exceptional bit:<br /> -- gote&#039;s king is usually 王 instead of 玉 by convention, <br /> -- but it&#039;s convenient to use the &#039;k&#039; code for both sente and gote and let the default character be side-dependent<br /> if pieceabbr:match(&#039;k&#039;) and side:match(&#039;g&#039;) then<br /> pieceabbr = &#039;ou&#039;<br /> end<br /> if pieceabbr:match(&#039;k&#039;) and side:match(&#039;s&#039;) then<br /> pieceabbr = &#039;gyoku&#039;<br /> end<br /> -- similar to above exception, reverse default<br /> if pieceabbr:match(&#039;ak&#039;) and side:match(&#039;s&#039;) then<br /> pieceabbr = &#039;ou&#039;<br /> end<br /> if pieceabbr:match(&#039;ak&#039;) and side:match(&#039;g&#039;) then<br /> pieceabbr = &#039;gyoku&#039;<br /> end<br /> -- convert abbreviation to Japanese character<br /> local piecechar = piecesymbol(pieceabbr)<br /> <br /> if ss:match(&#039;yy&#039;) or ss:match(&#039;gr&#039;) or ss:match(&#039;rat&#039;) or ss:match(&#039;lat&#039;) or ss:match(&#039;uat&#039;) or ss:match(&#039;dat&#039;) or <br /> ss:match(&#039;lra&#039;) or ss:match(&#039;las&#039;) or ss:match(&#039;ras&#039;) or ss:match(&#039;uda&#039;) or ss:match(&#039;das&#039;) or ss:match(&#039;uas&#039;) or <br /> ss:match(&#039;da&#039;) or ss:match(&#039;dau&#039;) or ss:match(&#039;dad&#039;) or ss:match(&#039;daus&#039;) or ss:match(&#039;dads&#039;) or ss:match(&#039;daa&#039;) or <br /> ss:match(&#039;daad&#039;) or ss:match(&#039;daau&#039;) or ss:match(&#039;daaus&#039;) or ss:match(&#039;daads&#039;) or ss:match(&#039;kar&#039;) or ss:match(&#039;kal&#039;) or <br /> ss:match(&#039;kadr&#039;) or ss:match(&#039;kadl&#039;) or ss:match(&#039;rah&#039;) or ss:match(&#039;lah&#039;) or ss:match(&#039;dah&#039;) or ss:match(&#039;uah&#039;) or <br /> ss:match(&#039;durh&#039;) or ss:match(&#039;dulh&#039;) or ss:match(&#039;ddrh&#039;) or ss:match(&#039;ddlh&#039;) or ss:match(&#039;ddl&#039;) or ss:match(&#039;ddr&#039;) or <br /> ss:match(&#039;dul&#039;) or ss:match(&#039;dur&#039;) then<br /> piecechar = &#039;[[File:shogi_&#039; .. ss .. &#039;22.svg|20px]]&#039;<br /> side = &#039;arrow&#039;<br /> color = &#039;arrow&#039;<br /> boldness = &#039;arrow&#039;<br /> end<br /> <br /> local result = {piecechar, side, color, boldness}<br /> return result<br /> end<br /> <br /> <br /> -- function makes a &lt;td&gt; containing the piece with CSS stuff<br /> -- uses the info from processString() to customize the CSS based on which side, color, and boldness<br /> function makeTD(stringarg)<br /> -- got to process the string argument into its informational bits<br /> -- this processedstring is an array (or whatever the equivalent is in Lua)<br /> local processedstring = processString(stringarg)<br /> -- saving the pieces of the array as separate objects to be referred to below<br /> local piecechar = processedstring[1]<br /> local side = processedstring[2]<br /> local color = processedstring[3]<br /> local bold = processedstring[4]<br /> <br /> -- i guess one needs a root node?<br /> local root = mw.html.create(&#039;&#039;)<br /> <br /> -- the default &lt;td&gt;<br /> local td = root:tag(&#039;td&#039;)<br /> td:css(&#039;border&#039;, &#039;black 1px solid&#039;)<br /> td:css(&#039;width&#039;, &#039;20px&#039;)<br /> td:css(&#039;height&#039;, &#039;20px&#039;)<br /> td:css(&#039;padding&#039;, &#039;0&#039;)<br /> td:css(&#039;line-height&#039;, &#039;0&#039;)<br /> td:css(&#039;font-family&#039;, &#039;&quot;Hiragino Mincho ProN&quot;, serif&#039;)<br /> <br /> if not side:match(&#039;arrow&#039;) then<br /> td:wikitext( piecechar )<br /> end<br /> <br /> -- g = gote<br /> -- gote should be upside down text<br /> if side:match( &#039;g&#039; ) then<br /> td:css(&#039;transform&#039;, &#039;rotate(180deg)&#039;)<br /> end<br /> <br /> -- for promoted pieces<br /> if color:match( &#039;red&#039; ) then<br /> -- this is a darkish reddish color<br /> td:css(&#039;color&#039;, &#039;#E00303&#039;)<br /> end<br /> <br /> -- for bold pieces<br /> if bold:match( &#039;bold&#039; ) then<br /> td:css(&#039;font-weight&#039;, &#039;bolder&#039;)<br /> -- traditionally bold type is gothic (sans serif) in Japanese typesetting of shogi diagrams within Japanese shogi books<br /> td:css(&#039;font-family&#039;, &#039; HiraginoSans-W5, sans-serif&#039;)<br /> end<br /> <br /> -- for arrow svgs <br /> if side:match(&#039;arrow&#039;) then<br /> td:css(&#039;padding&#039;, &#039;0&#039;)<br /> td:css(&#039;width&#039;, &#039;20px&#039;)<br /> td:css(&#039;height&#039;, &#039;20px&#039;)<br /> td:css(&#039;font-size&#039;, &#039;1px&#039;)<br /> td:css(&#039;line-height&#039;, &#039;0&#039;)<br /> td:wikitext( piecechar )<br /> end<br /> return tostring(root)<br /> end<br /> <br /> <br /> -- function makes the shogi diagram<br /> -- this is basically a &lt;div&gt; enclosing a .css &lt;div&gt; wrapper with a &lt;table&gt; inside<br /> function shogiboard(args)<br /> -- these are the column coordinate labels 9-1<br /> local colLabels = {&#039;9&#039;, &#039;8&#039;, &#039;7&#039;, &#039;6&#039;, &#039;5&#039;, &#039;4&#039;, &#039;3&#039;, &#039;2&#039;, &#039;1&#039;, &#039;&amp;nbsp;&#039;}<br /> -- these are the row coordinate labels a-i (western notation)<br /> local rowLabels = {&#039;1&#039;, &#039;2&#039;, &#039;3&#039;, &#039;4&#039;, &#039;5&#039;, &#039;6&#039;, &#039;7&#039;, &#039;8&#039;, &#039;9&#039;}<br /> -- these are the row coordinate labels 1-9 (Japanese notation)<br /> -- this isn&#039;t set up for use yet<br /> local rowLabelsJP = {&#039;一&#039;, &#039;二&#039;, &#039;三&#039;, &#039;四&#039;, &#039;五&#039;, &#039;六&#039;, &#039;七&#039;, &#039;八&#039;, &#039;九&#039;}<br /> <br /> local headerarg = args[2]<br /> local toppieceinhandarg = args[3]<br /> <br /> local root = mw.html.create(&#039;div&#039;)<br /> <br /> -- &lt;div&gt; wrapper<br /> local shogiboardwrapper = root:tag(&#039;div&#039;)<br /> :addClass(&#039;shogiboardwrapper&#039;)<br /> :css(&#039;padding-left&#039;, &#039;4px&#039;)<br /> :css(&#039;padding-bottom&#039;, &#039;2px&#039;)<br /> <br /> -- the diagram header/caption<br /> local headerstring = mw.text.trim(headerarg)<br /> local header = shogiboardwrapper:tag(&#039;div&#039;)<br /> header:css(&#039;padding&#039;, &#039;0&#039;)<br /> header:wikitext(headerstring)<br /> header:css(&#039;font-size&#039;, &#039;14px&#039;)<br /> <br /> -- this is the &#039;piece-in-hand&#039; argument for gote<br /> -- strip whitespace<br /> local strippedpieceinhandtop = mw.text.trim(toppieceinhandarg) or &#039;&#039;<br /> -- put it in a &lt;div&gt; with .css formating<br /> local pieceinhandtopdiv = shogiboardwrapper:tag(&#039;div&#039;)<br /> pieceinhandtopdiv:css(&#039;padding&#039;, &#039;0&#039;)<br /> pieceinhandtopdiv:css(&#039;font-size&#039;, &#039;12px&#039;)<br /> pieceinhandtopdiv:wikitext(&#039;☖ pieces in hand: &#039;)<br /> -- i was going to put the actual argument text into conditional &lt;span&gt; .css formating, but i couldn&#039;t get the logical test in an if/else structure right...<br /> local piecesinhandtopspan = pieceinhandtopdiv:tag(&#039;span&#039;)<br /> piecesinhandtopspan:css(&#039;font-size&#039;, &#039;13px&#039;)<br /> piecesinhandtopspan:wikitext(strippedpieceinhandtop)<br /> <br /> -- the shogi table<br /> local shogitable = shogiboardwrapper:tag(&#039;table&#039;)<br /> :addClass(&#039;shogitable&#039;)<br /> :attr(&#039;border&#039;, &#039;1&#039;)<br /> :css(&#039;border-collapse&#039;, &#039;collapse&#039;)<br /> :css(&#039;border&#039;, &#039;none&#039;)<br /> :css(&#039;padding-top&#039;, &#039;0&#039;)<br /> :css(&#039;background-color&#039;, &#039;white&#039;)<br /> <br /> -- font size for the shogi piece text<br /> piecefontsize = &#039;17px&#039;<br /> -- font size for the column/row piece coordinate labels (9-1) and (a-i)<br /> colrowfontsize = &#039;11px&#039;<br /> -- padding amount for the row piece coordinate labels (a-i)<br /> padrowlab = &#039;1px&#039;<br /> <br /> -- the row for the column coordinate labels<br /> local columnlabelrow = shogitable:tag(&#039;tr&#039;)<br /> :css(&#039;font-size&#039;, colrowfontsize)<br /> :css(&#039;background-color&#039;, &#039;#f9f9f9&#039;)<br /> -- iterating over the column label to put each label in a &lt;td&gt;<br /> for i,v in ipairs(colLabels) do <br /> local td = columnlabelrow:tag(&#039;td&#039;)<br /> :css(&#039;border&#039;, &#039;none&#039;)<br /> :css(&#039;width&#039;, &#039;20px&#039;)<br /> :css(&#039;height&#039;, &#039;5px&#039;)<br /> :wikitext( v )<br /> end<br /> <br /> -- iterate over the 81 shogi piece arguments (left to right, top to bottom)<br /> -- i couldn&#039;t figure out how to do this is in a clever loopy way as i couldn&#039;t figure out how to close the html tags<br /> -- whatever, it&#039;s repetitive, but it works<br /> <br /> -- index number displacement/offset<br /> -- this is just the number of arguments that precede the 81 shogi piece arguments that are in the html &lt;table&gt;<br /> -- i just keep the piece arguments as indexes 1-81, then add nx to the index value<br /> nx = 3<br /> <br /> -- the row for the shogi pieces<br /> -- row 1<br /> for icols = 0,8 do<br /> local trow = shogitable:tag(&#039;tr&#039;)<br /> :css(&#039;font-size&#039;, piecefontsize)<br /> -- put a single piece into a &lt;td&gt;<br /> -- iterate over 9 pieces in the row<br /> <br /> for irow = (icols*9)+1,((icols+1)*9) do<br /> trow:wikitext( makeTD(args[(irow+nx)]) )<br /> end<br /> -- add row coordinate label &lt;td&gt;<br /> local rowlabel = trow:tag(&#039;td&#039;)<br /> :css(&#039;border&#039;, &#039;none&#039;)<br /> :css(&#039;font-size&#039;, colrowfontsize)<br /> :css(&#039;padding-left&#039;, padrowlab)<br /> :css(&#039;padding-top&#039;, &#039;0&#039;)<br /> :css(&#039;padding-bottom&#039;, &#039;0&#039;)<br /> :css(&#039;background-color&#039;, &#039;#f9f9f9&#039;)<br /> :wikitext( rowLabels[icols] )<br /> end<br /> -- this is the &#039;piece-in-hand&#039; argument for sente (same as above for gote)<br /> -- only difference is the black shogi piece glyph (☗)<br /> local strippedpieceinhandbottom = mw.text.trim(args[81+1+nx]) or &#039;&#039; <br /> local pieceinhandbottomdiv = shogiboardwrapper:tag(&#039;div&#039;)<br /> pieceinhandbottomdiv:css(&#039;padding&#039;, &#039;0&#039;)<br /> pieceinhandbottomdiv:css(&#039;font-size&#039;, &#039;12px&#039;)<br /> pieceinhandbottomdiv:wikitext(&#039;☗ pieces in hand: &#039;)<br /> local piecesinhandbottomspan = pieceinhandbottomdiv:tag(&#039;span&#039;)<br /> piecesinhandbottomspan:css(&#039;font-size&#039;, &#039;13px&#039;)<br /> piecesinhandbottomspan:wikitext(strippedpieceinhandbottom)<br /> <br /> return tostring(root)<br /> end<br /> <br /> <br /> -----------------------<br /> -- main function <br /> -----------------------<br /> <br /> function shogiobject.board(frame)<br /> -- need to use getParent().args for reasons i dont understand<br /> local args = frame:getParent().args<br /> return shogiboard(args)<br /> end<br /> <br /> return shogiobject</div> Techie3