How to map graphic tileset to ascii symbols?

Hello!

I’m very happy to find ‘Tiled’ - this is really beautiful programm!

I’m rookie developer and working at online roguelike game Angband Online which is based at Angband.

In my game I got maps which consist of simple ascii maps, for example:

https://pastecode.xyz/view/b70cae17 - this is a town

https://pastecode.xyz/view/d239c105 - this is a map ‘legend’, so # is a wall, O is a road etc

Each ascii tile at the map got graphical tile which is bound to it. So user got an option - to play in pure ascii or with tileset.

I’ve installed ‘Tiled’, created new .tmx with proper size and imported there graphical tileset as .tsx. Now I’m able to draw everything with tiles, not with ascii characters and it’s great! The problem is:
how to export my map which I’ve made in ‘Tiled’ as a pure ascii map (examples of which I linked above)?

I’ve read the ‘Tiled’ documentation and noted the option to export as .csv while having ‘name’ property with acsii symbol for each tile. But it using commas between symbols and also fills empty spots with ‘-1’ (and I need to leave them empty). The only way to solve it (which I found) is to replace ‘-1’ and commans in text editor with spaces which isn’t really comfortable as I need a lot of testing during maps drawing. Also I’ve checked .tmx file format documentation (which also uses .csv), but I failed to understand - is there way to solve this issue there…

Please help, guys! Are there any way to customize output to pure and simple ascii map without additional symbols? So each tile (picture) would have one property (ascii character) at output file; and the same time output file won’t have commas and empty spots would be marked as spaces.

1 Like

The easiest way to do this is with Python scripting.

The example in the docs shows a basic example, pretty much the same as a csv. All you would have to do is slightly modify that script to do what you want. Now, depending on how familiar you are with coding (and the Python language), you may find this to be difficult to understand. If you need any assistance, let me know!

1 Like

Tryed it with the example script. Working on windows with Tiled v. 1.2.2, Python 3.7. installed.
Added script to C:\Users\ <user> \.tiled nothing seems to happen. No new export option in Export As dialog.
Also I see this in plugins:
image

Example which output I have right now: https://pastecode.xyz/view/73adf063
Which output I need: https://pastecode.xyz/view/9f4f9498
(additionally I need to have a frame and each stroke should start with ‘D:’… I wander is it also possible somehow)?

Thank you!

p.s.
After I’ll learn a bit, I’m going to make series of video tutorials about ‘Tiled’ at my youtube channel :wink:

The Python scripting is relatively hard to get working since the upgrade to Python 3, because you need exactly the version of Python that Tiled was built against installed on your system (and it needs to match the architecture of the Tiled you installed - 32 or 64 bits).

In the meantime, the development snapshots have gained the option of defining map export formats in JavaScript. This works on all platforms since the JavaScript engine is shipping with Tiled. The extension mechanism is subject to change, but it’s documented at:

https://doc.mapeditor.org/en/latest/reference/scripting/#script-registermapformat

The best place to define your custom format is currently in the startup script.

1 Like

Thanks for the answer @bjorn! Yeah I love that option. But unfortunately having problems with it too.
Asked a question in separate thread:

https://github.com/ilius33/TiledToAngbandExport made a startup.js script for your needs.

3 Likes

awesome :smiley: THANKS! =)

I see there’s an upcoming game jam on itch.io where this script could prove useful:

2 Likes