<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
	<channel>
		<title><![CDATA[Teeworlds Forum — [TUTORIAL] Automapper: make your own rules! (0.7.x)]]></title>
		<link>https://www.teeworlds.com/forum/viewtopic.php?id=12648</link>
		<atom:link href="https://www.teeworlds.com/forum/extern.php?action=feed&amp;tid=12648&amp;type=rss" rel="self" type="application/rss+xml" />
		<description><![CDATA[The most recent posts in [TUTORIAL] Automapper: make your own rules! (0.7.x).]]></description>
		<lastBuildDate>Fri, 28 Dec 2018 01:44:49 +0000</lastBuildDate>
		<generator>PunBB</generator>
		<item>
			<title><![CDATA[Re: [TUTORIAL] Automapper: make your own rules! (0.7.x)]]></title>
			<link>https://www.teeworlds.com/forum/viewtopic.php?pid=122325#p122325</link>
			<description><![CDATA[<div class="quotebox"><cite>Dune wrote:</cite><blockquote><p><em>*sleeps*</em></p></blockquote></div><p>Good night. <img src="https://www.teeworlds.com/forum/img/smilies/smile.png" alt="smile" /></p><p>Thanks for the tutorial!</p>]]></description>
			<author><![CDATA[null@example.com (heinrich5991)]]></author>
			<pubDate>Fri, 28 Dec 2018 01:44:49 +0000</pubDate>
			<guid>https://www.teeworlds.com/forum/viewtopic.php?pid=122325#p122325</guid>
		</item>
		<item>
			<title><![CDATA[Re: [TUTORIAL] Automapper: make your own rules! (0.7.x)]]></title>
			<link>https://www.teeworlds.com/forum/viewtopic.php?pid=122323#p122323</link>
			<description><![CDATA[<p><em>*sleeps*</em></p>]]></description>
			<author><![CDATA[null@example.com (Dune)]]></author>
			<pubDate>Thu, 27 Dec 2018 21:43:04 +0000</pubDate>
			<guid>https://www.teeworlds.com/forum/viewtopic.php?pid=122323#p122323</guid>
		</item>
		<item>
			<title><![CDATA[[TUTORIAL] Automapper: make your own rules! (0.7.x)]]></title>
			<link>https://www.teeworlds.com/forum/viewtopic.php?pid=122322#p122322</link>
			<description><![CDATA[<p>So jxsl13 made this very good tutorial here for the 0.6.x automapper: <a href="https://www.teeworlds.com/forum/viewtopic.php?pid=92492">https://www.teeworlds.com/forum/viewtopic.php?pid=92492</a><br />0.7 uses a different format, JSON, although the idea is the same.</p><p>A recent <a href="https://www.teeworlds.com/forum/viewtopic.php?id=12622">client mod</a> feature to use the automapper ingame revived some interest in making automapper rules:<br /><span class="postimg"><img src="https://i.imgur.com/9PRaFhL.jpg" alt="https://i.imgur.com/9PRaFhL.jpg" /></span></p><h5>Tileset coordinates</h5><p>I&#039;ll rewrite jxsl13&#039;s tutorial below, starting with his image:</p><p><span class="postimg"><img src="https://www.teeworlds.com/forum/misc.php?action=pun_attachment&amp;item=33&amp;download=0" alt="https://www.teeworlds.com/forum/misc.php?action=pun_attachment&amp;amp;item=33&amp;amp;download=0" /></span></p><p>This is what a tileset looks like (grass_main, here), and - more importantly - how you get the coordinates for each tile (add 16 per row). For example, the dark shadow square is <strong>128+14=142</strong> :)</p><br /><p>Now, there is already some existing rules in the official Teeworlds, for grass_main (more basic ones can be found in the mod linked above). Let&#039;s jump right into it and demystify the format.</p><br /><h5>The framework</h5><p>So this is the basics, the root:<br /></p><div class="codebox"><pre><code>{&quot;tileset&quot;: [
    {&quot;grass&quot;:
        {
            &quot;basetile&quot;: 1,

            &quot;rules&quot;: [
                
            ]
        }
    }]
}</code></pre></div><p>Just copy it and change the name of the tileset (&quot;grass&quot;). We will write our rules in between the [ ] brackets of &quot;rules&quot;. Nothing else is really interesting here.<br />By default, the whole map is mapped with the &quot;base&quot; tile &quot;1&quot;, that is: <span class="postimg"><img src="https://i.imgur.com/qrqUehu.png" alt="https://i.imgur.com/qrqUehu.png" /></span>.</p><h5>Your first rule</h5><p>Let&#039;s write a basic rule:<br />I want every single solid tile that has <span class="bbu">empty space above</span> to look like this: <span class="postimg"><img src="https://i.imgur.com/JZTQn1P.jpg" alt="https://i.imgur.com/JZTQn1P.jpg" /></span>. Sounds good?</p><p>So let&#039;s build it. First, let&#039;s write the index we want:<br /></p><div class="codebox"><pre><code>            {
                &quot;index&quot;: 16,
                &quot;condition&quot;: [
                ]
            }</code></pre></div><p>This lacks <strong>a condition</strong>. Every rule needs a condition (or several). Here, our condition is: <span class="bbu">&quot;empty space above&quot;</span>. Well, alright. </p><ul><li><p>&quot;empty space&quot; translates as</p></li></ul><div class="codebox"><pre><code>&quot;value&quot;: &quot;empty&quot;</code></pre></div><p><em>easy, right?</em><br /></p><ul><li><p>&quot;above&quot; translates as:</p></li></ul><div class="codebox"><pre><code>&quot;x&quot;: 0, &quot;y&quot;: -1</code></pre></div><p><em>numbers take no &quot; &quot; double quotes</em></p><p>That one explains itself with this image<br /><span class="postimg"><img src="https://i.imgur.com/ckIhWdq.png" alt="https://i.imgur.com/ckIhWdq.png" /></span><br />The tile <strong>above</strong> our coordinates is placed at the (relative) coordinates x=0 y=-1<br />To get the tile on the bottom right, you would use x=1 y=1, etc.<br />For a tile on the left, use x=-1 y=0</p><p>Now your rule looks like:<br /></p><div class="codebox"><pre><code>            {
                &quot;index&quot;: 16,
                &quot;condition&quot;: [
                    {&quot;x&quot;: 0, &quot;y&quot;: -1, &quot;value&quot;: &quot;empty&quot;},
                ]
            }</code></pre></div><p>That works!<br />Let&#039;s see the full .json:<br /></p><div class="codebox"><pre><code>{&quot;tileset&quot;: [
    {&quot;grass&quot;:
        {
            &quot;basetile&quot;: 1,

            &quot;rules&quot;: [
            {
                &quot;index&quot;: 16,
                &quot;condition&quot;: [
                    {&quot;x&quot;: 0, &quot;y&quot;: -1, &quot;value&quot;: &quot;empty&quot;},
                ]
            }]
        }
    }]
}</code></pre></div><p>Now, dm1 looks like:<br /><span class="postimg"><img src="https://i.imgur.com/msja7S8.jpg" alt="https://i.imgur.com/msja7S8.jpg" /></span></p><p>Not bad! Okay, not that good either, but it was your first rule after all :D</p><br /><h5>A small improvement</h5><p>I would like to make a small improvement. The left corner: <span class="postimg"><img src="https://i.imgur.com/K4HXui7.jpg" alt="https://i.imgur.com/K4HXui7.jpg" /></span><br />When should this one be printed? What are the conditions? Think.<br />.<br />..<br />...</p><p>It should be:<br /></p><ul><li><p>above (0,-1) is empty</p></li><li><p>left (-1,0) is empty</p></li><li><p>right (1,0) is full</p></li></ul><p><strong>Edit:</strong> probably &quot;bottom is full&quot; too. Whoops!</p><p>So let&#039;s write it!<br /></p><div class="codebox"><pre><code>            {
                &quot;index&quot;: 32,
                &quot;condition&quot;: [
                    {&quot;x&quot;: 0, &quot;y&quot;: -1, &quot;value&quot;: &quot;empty&quot;},
                    {&quot;x&quot;: -1, &quot;y&quot;: 0, &quot;value&quot;: &quot;empty&quot;},
                    {&quot;x&quot;: 1, &quot;y&quot;: 0, &quot;value&quot;: &quot;full&quot;},
                ]
            }</code></pre></div><p>Here is the full JSON file to try: <a href="https://pastebin.com/raw/P4AmtCLD">https://pastebin.com/raw/P4AmtCLD</a> (grass_main.json)<br />Be careful about the order of your rules! They are applied in the order they are written in. If something doesn&#039;t work, it&#039;s probably that. Otherwise, check the console log of your client.</p><p>So let&#039;s see what this looks like:<br /><span class="postimg"><img src="https://i.imgur.com/nhFJnvD.jpg" alt="https://i.imgur.com/nhFJnvD.jpg" /></span></p><p>Dang, sexy!</p><br /><br /><p>So that&#039;s it for the basics! Those should suffice for 90% of the tiles.<br />I&#039;m getting sleepy, we&#039;ll see a few more advanced techniques tomorrow.<br />At the end of the little journey, you&#039;ll be able to automap dm1... almost identically!</p><p><span class="postimg"><img src="https://i.imgur.com/kqdi783.gif" alt="https://i.imgur.com/kqdi783.gif" /></span></p><p>See you tomorrow! :)<br />PS: don&#039;t hesitate to ask questions. No dumb questions!</p>]]></description>
			<author><![CDATA[null@example.com (Dune)]]></author>
			<pubDate>Thu, 27 Dec 2018 21:42:51 +0000</pubDate>
			<guid>https://www.teeworlds.com/forum/viewtopic.php?pid=122322#p122322</guid>
		</item>
	</channel>
</rss>
