1 (edited by Dune 2018-12-28 03:49:15)

Topic: [TUTORIAL] Automapper: make your own rules! (0.7.x)

So jxsl13 made this very good tutorial here for the 0.6.x automapper: https://www.teeworlds.com/forum/viewtopic.php?pid=92492
0.7 uses a different format, JSON, although the idea is the same.

A recent client mod feature to use the automapper ingame revived some interest in making automapper rules:
https://i.imgur.com/9PRaFhL.jpg

Tileset coordinates

I'll rewrite jxsl13's tutorial below, starting with his image:

https://www.teeworlds.com/forum/misc.php?action=pun_attachment&item=33&download=0

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 128+14=142 :)


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's jump right into it and demystify the format.


The framework

So this is the basics, the root:

{"tileset": [
    {"grass":
        {
            "basetile": 1,

            "rules": [
                
            ]
        }
    }]
}

Just copy it and change the name of the tileset ("grass"). We will write our rules in between the [ ] brackets of "rules". Nothing else is really interesting here.
By default, the whole map is mapped with the "base" tile "1", that is: https://i.imgur.com/qrqUehu.png.

Your first rule

Let's write a basic rule:
I want every single solid tile that has empty space above to look like this: https://i.imgur.com/JZTQn1P.jpg. Sounds good?

So let's build it. First, let's write the index we want:

            {
                "index": 16,
                "condition": [
                ]
            }

This lacks a condition. Every rule needs a condition (or several). Here, our condition is: "empty space above". Well, alright.

  • "empty space" translates as

"value": "empty"

easy, right?

  • "above" translates as:

"x": 0, "y": -1

numbers take no " " double quotes

That one explains itself with this image
https://i.imgur.com/ckIhWdq.png
The tile above our coordinates is placed at the (relative) coordinates x=0 y=-1
To get the tile on the bottom right, you would use x=1 y=1, etc.
For a tile on the left, use x=-1 y=0

Now your rule looks like:

            {
                "index": 16,
                "condition": [
                    {"x": 0, "y": -1, "value": "empty"},
                ]
            }

That works!
Let's see the full .json:

{"tileset": [
    {"grass":
        {
            "basetile": 1,

            "rules": [
            {
                "index": 16,
                "condition": [
                    {"x": 0, "y": -1, "value": "empty"},
                ]
            }]
        }
    }]
}

Now, dm1 looks like:
https://i.imgur.com/msja7S8.jpg

Not bad! Okay, not that good either, but it was your first rule after all :D


A small improvement

I would like to make a small improvement. The left corner: https://i.imgur.com/K4HXui7.jpg
When should this one be printed? What are the conditions? Think.
.
..
...

It should be:

  • above (0,-1) is empty

  • left (-1,0) is empty

  • right (1,0) is full

Edit: probably "bottom is full" too. Whoops!

So let's write it!

            {
                "index": 32,
                "condition": [
                    {"x": 0, "y": -1, "value": "empty"},
                    {"x": -1, "y": 0, "value": "empty"},
                    {"x": 1, "y": 0, "value": "full"},
                ]
            }

Here is the full JSON file to try: https://pastebin.com/raw/P4AmtCLD (grass_main.json)
Be careful about the order of your rules! They are applied in the order they are written in. If something doesn't work, it's probably that. Otherwise, check the console log of your client.

So let's see what this looks like:
https://i.imgur.com/nhFJnvD.jpg

Dang, sexy!



So that's it for the basics! Those should suffice for 90% of the tiles.
I'm getting sleepy, we'll see a few more advanced techniques tomorrow.
At the end of the little journey, you'll be able to automap dm1... almost identically!

https://i.imgur.com/kqdi783.gif

See you tomorrow! :)
PS: don't hesitate to ask questions. No dumb questions!

Post's attachments

Attachment icon automapper_tutorial.png 225.55 kb, 254 downloads since 2018-12-27 

Not Luck, Just Magic.

2

Re: [TUTORIAL] Automapper: make your own rules! (0.7.x)

*sleeps*

Not Luck, Just Magic.

3

Re: [TUTORIAL] Automapper: make your own rules! (0.7.x)

Dune wrote:

*sleeps*

Good night. smile

Thanks for the tutorial!