Automapper Tutorial

Read tips and guides about teeworlds-related subjects (mapping, compiling, ..).
Post Reply
User avatar
timakro
Posts: 414
Joined: Mon May 05, 2014 6:05 pm
Location: Germany
Player profile: http://ddnet.tw/players/timakro/
Mapper profile: http://ddnet.tw/mappers/timakro/
Clan: unique

Automapper Tutorial

Post by timakro »

Automapper Tutorial
written by DoNe, slightly edited by Index

Image
EnglishShow
What is a automapper and how to use it?

The automapper is a tool to make mapping easier for mappers. Instead of placing the round edges of freeze by hand you could make a simple automapper rule that applys a few rules to a entiere tile layer. Every automapper is made for a specific tileset. A tileset can have more than one automapper. All automapper rules are located in your teeworlds path at data/editor/. There is a tileset.rules textfile for every tileset that has an automapper. Each tileset.rules file can contain one or more automappers. Inside a file every automapper starts with the line "[automapper_name]". For example in the file grass_main.rules there is a automapper called Grass it starts at the line "[Grass]" inside the file. To use it you have to create a tilelayer with the tileset grass_main in the mapeditor. Rightclick on the layer and click on "Auto map". To start automapping click "Grass".

How does a automapper work?

First we have to know that every tile in a layer has an index. If you enable the info option at the top of your editor you can see the index of every tile in the tileselection by holding space. A automapper contains multiple rules. A rules contains conditions and a index to place if the conditions are true. For example a condition could be true if the block above the block that is checked has a specific index. Then the block that is checked would be replaced with the index you set before. For every rule the automapper checks every block in the layer. And if a condition is true the checked block will be replaced.

How to create my own automapper?

You start your automapper with it's name like i explained before. Our test automapper will be called Test.

Code: Select all

[Test]
You can start your automapper now by adding a simple rule. We want to place index 32 at the checked block if the block thats two blocks under the checked block is index 4 and the block thats one block right of the checked block is index 0.

Code: Select all

Index 32
Pos 0 2 INDEX 4
Pos 1 0 INDEX 0
You can also use FULL and EMPTY instead of the index. We want to place index 7 at the checked block if the block thats one block left of the checked block is 0 and the block thats one block right and two blocks down of the checked block is index one or higher.

Code: Select all

Index 7
Pos -1 0 EMPTY
Pos 1 2 FULL
It looks like there were two conditions to place index 32 and index 7. But thats wrong. The game adds a default condition to every rule. The default rule is "Pos 0 0 FULL". To prevent this default rule we can use "NoDefaultRule". This will place index 19 at the checked block if the block above the checked block is EMPTY and will not look at the checked block itself.

Code: Select all

Index 19
NoDefaultRule
Pos 0 -1 EMPTY
If you want to place flipped or rotated tiles you can use the flags "XFLIP", "YFLIP" and "ROTATE. This will place index 12 xflipped, yflipped and rotated at the checked block if the block above the checked block is FULL.

Code: Select all

Index 12 XFLIP YFLIP ROTATE
Pos 0 -1 FULL
This will place index 25 yflipped at the checked block if the block above the checked block is index 17.

Code: Select all

Index 25 YFLIP
Index 0 -1 INDEX 17
That’s all you should know to create your own automapper. If there is anything left, you can ask here.
Good luck and thanks for reading.
Image
FrenchShow
Qu'est-ce que Automapper et comment l'utiliser?

L'outil Automapper sert à réaliser des maps plus facilement. Plutôt que de placer les bords d'ombre arrondis à la main, vous pouvez établir une simple règle automapper qui s'appliquera au calque. Chaque Automapper est fait pour un tileset spécifique. Un tileset peut avoir plusieurs automapper. Toutes les règles automappers sont situés dans votre dossier TeeWorls data/editor/. Il y a des fichiers texte tileset.rules pour chaque tileset contenant un automapper. Chaque fichier tileset.rules peut contenir un ou plusieurs automappers. Dans un fichier, tous les automappers commencent par la ligne "[automapper_name]". Par exemple dans le fichier grass_main.rules, il y a un automapper nommé "Grass" qui démarre avec la ligne "[Grass]". Pour l'utiliser, vous devez créer un tilelayer avec le tileset grass_main dans l'éditeur de map. Clique droit sur le calque puis cliquez sur "Auto map". Pour démarrer l'automapping, cliquez "Grass".

Comment fonctionne l'automapper?

Pour commencer nous devons savoir que chaque tile dans un calque a un index. Si vous activez l'option info en haut de votre éditeur, vous pouvez voir l'index de chaque tile dans le tileselection en maintenant la touche espace. Un automapper contient plusieurs règles. Une règle contient des conditions et un index à placer si la condition est vraie. Par exemple la condition peut être vraie si le bloque au-dessus du bloque qui est identifié a un index spécifique. Alors le bloque qui est vérifié devrait se trouver remplacer par l'index que vous avez défini avant.Pour chaque règle, l'automapper vérifie chaque bloque du calque. Et si une condition est vraie, le bloque vérifié sera remplacé.

Comment créer mon propre automapper?

Vous commencez votre automapper avec son nom comme je l'ai expliqué avant. Notre automapper de test s'appellera "Test".

Code: Select all

[Test]
Vous pouvez maintenant débuter votre automapper en ajoutant une règle simple. On veut placer l'index 32 au bloque vérifié si celui se situant 2 bloques en-dessous a l'index 4 et si le bloque qui est a un bloque à droite du vérifié a l'index 0.

Code: Select all

Index 32
Pos 0 2 Index 4
Pos 1 0 Index 0
Vous pouvez aussi utiliser FULL et EMPTY plutôt qu'un index. On veut placer l'index 7 au bloque vérifié si l'index du bloque à sa gauche est 0 et si le bloque 2 bloques en-dessous et 1 bloque à droite a un index de 1 ou plus.

Code: Select all

Index 7
Pos -1 0 EMPTY
Pos 1 2 FULL
On dirait qu'il y avait 2 conditions pour placer l'index 32 et l'index 7, mais c'est faux. Le jeu ajoute une condition par défaut à chaque règle. La règle par défaut est "Pos 0 0 FULL". Pour contrer cette valeur par défaut on peu utiliser "NoDefaultRule". L'index du bloque vérifié deviendra 19 si le bloque au-dessus est "EMPTY" et si il ne ressemble pas au bloque lui-même.

Code: Select all

Index 19
NoDefaultRule
Pos 0 -1 EMPTY
Si vous voulez placer un tile inversé ou tourné vous pouvez utiliser les indicateur "XFLIP", "YFLIP" et "ROTATE". Ca donnera l'index 12 "xflipped", "yflipped" et "rotated" au bloque vérifier si celui au-dessus est "FULL".

Code: Select all

Index 12 XFLIP YFLIP ROTATE
Pos 0 -1 FULL
Ici on va placer l'index 25 "yflipped" au bloque vérifié si celui au-dessus a un index de 17.

Code: Select all

Index 25 YFLIP
Index 0 -1 Index 17
translation by o_tee_one
Last edited by timakro on Sat Dec 27, 2014 8:44 pm, edited 1 time in total.
User avatar
timakro
Posts: 414
Joined: Mon May 05, 2014 6:05 pm
Location: Germany
Player profile: http://ddnet.tw/players/timakro/
Mapper profile: http://ddnet.tw/mappers/timakro/
Clan: unique

Re: Automapper Tutorial by DoNe

Post by timakro »

thank you for the translation o_tee_one!
o_tee_one
Posts: 19
Joined: Wed Nov 12, 2014 5:28 pm
Player profile: http://ddnet.tw/players/o_tee_one/

Re: Automapper Tutorial by DoNe

Post by o_tee_one »

Pleasure :).
BJ_Umut
Posts: 1
Joined: Sat Jun 10, 2023 4:32 pm

Re: Automapper Tutorial

Post by BJ_Umut »

Can you or someone else give the automapper for generic_unhookable random silver
User avatar
deen
TECHNICAL Team
Posts: 3575
Joined: Mon May 05, 2014 2:30 pm
Player profile: https://ddnet.org/players/deen/
Discord: deen#5910

Re: Automapper Tutorial

Post by deen »

BJ_Umut wrote: Sat Jun 10, 2023 4:35 pm Can you or someone else give the automapper for generic_unhookable random silver
This thread is 9 years old, so maybe it makes more sense to ask on ddnet discord: https://ddnet.org/discord
Post Reply

Who is online

Users browsing this forum: No registered users and 0 guests