1 (edited by erd 2012-01-08 01:44:27)

Topic: TeeworldsMapLib

Are you a developer? Did you ever wanted to hack a teeworlds map without the client, but with a program? Or do you want to build applications, which need to read the data of a teeworlds map file, or even change and create maps? Then this is what you always wanted!

SushiTee and me developed a python tool which can exactly do that: giving you a nice interface without needing you to worry about stuff like the teeworlds fileheader or offsets.

A small taste:

>>> from tml.tml import Teemap
>>> t = Teemap('tml/maps/dm1') # example
>>> t.groups
[<Group (1)>, <Group (2)>, <Group (2)>, <Group (1)>, <Group (1)>, <Group (1)>, <Group (6)>]
>>> t.groups[6].layers
[<Tilelayer (60x50)>, <Tilelayer (60x50)>, <Game layer (60x50)>, <Tilelayer (60x50)>, <Tilelayer (60x50)>, <Tilelayer (60x50)>]
>>> t.images
[<Image (bg_cloud1)>, <Image (bg_cloud2)>, <Image (bg_cloud3)>, <Image (grass_doodads)>, <Image (grass_main)>, <Image (mountains)>, <Image (sun)>]
>>> t.images[2].save('cloud3.png')
>>> t.save('my_great_map')

... and so on.

We hope that you can build great programs for teeworlds players with the help of tml.

Tml is still under development (and we should think about giving proper versionnumbers big_smile), but its already usable (at least all things mentioned in the documentation).

Check out the repository at https://github.com/erdbeere/tml/ and the docs at http://sushitee.github.com/tml or http://erdbeere.github.com/tml/

Tools / sites which use tml:

Have fun!

2

Re: TeeworldsMapLib

Been trying it before, but couldn't figure out how it was working. Thanks for the explanation and good job! smile

Not Luck, Just Magic.

3

Re: TeeworldsMapLib

Great idea. smile
But the interface of this library seems pretty low-level, I'd like to see some high level stuff like automapper or so smile

4

Re: TeeworldsMapLib

automapper would be a feature of an application which uses tml wink
tml is supposed to do the low level shit which would be a pain in the ass if u have to care about that yourself

uptee - a simple web interface for hosting and maintaining teeworlds servers
teerace - a website gathering results of trusted Race-mod servers providing global ranking and statistics
*gV* rox ^^

5

Re: TeeworldsMapLib

Sushi Tee wrote:

automapper would be a feature of an application which uses tml wink
tml is supposed to do the low level shit which would be a pain in the ass if u have to care about that yourself

But heinrich is right, the project would have a lot larger audience if you would code a minimalistic UI for it.

Not Luck, Just Magic.

6

Re: TeeworldsMapLib

a mapviewer would be great but anyway... tml is not supposed to have such features... this would be another application using tml... maybe we will write something like that

uptee - a simple web interface for hosting and maintaining teeworlds servers
teerace - a website gathering results of trusted Race-mod servers providing global ranking and statistics
*gV* rox ^^

7

Re: TeeworldsMapLib

A map viewer was already written by Choupom.

8

Re: TeeworldsMapLib

is completely different from what i mean though xD

uptee - a simple web interface for hosting and maintaining teeworlds servers
teerace - a website gathering results of trusted Race-mod servers providing global ranking and statistics
*gV* rox ^^

9

Re: TeeworldsMapLib

Is this still working?

10

Re: TeeworldsMapLib

The map format haven't got any updates so it should. I'm using it for converting maps into a json format.

11 (edited by Zeta-Hoernchen 2013-04-11 09:10:34)

Re: TeeworldsMapLib

Hmm i have some problems:
1. Looks like DDRace maps have to be older to be loadable with TML.
2. If i just do

tm = Teemap("myMap.map")
tm.save("myMap.map")

all the game layers are renamed to "Tiles"
3. If i do

tm = Teemap("myDDRaceMap.map")
tm.layer[0].name = "foobar"
tm.save("test.map")

on a DDRace map where layer 0 is not a game layer, the Teeworlds client can't open the map anymore.
4. Same happens for

tm = Teemap("MyDDRaceMap.map")
from tml.items import Tile
tm.layers[0].get_tile(0,0).vflip()
tm.save("test.map")

Looks like the format did change...

12

Re: TeeworldsMapLib

Zeta-Hoernchen wrote:

[...] all the game layers are renamed to "Tiles" [...]

I would like to test it on my own, could you link an example map?

13

Re: TeeworldsMapLib

Just use a default map like ctf1.
And 1. perhaps only applies to DDRace maps.

14

Re: TeeworldsMapLib

One problem that I had at opening new tw and ddrace maps was that tml wasn't able to parse map informations like (author, map_version e.g.):

File "tml/datafile.py", line 94, in __init__
    settings = item_data[:items.Info.type_size]
ValueError: need more than 5 values to unpack

I just commented that feature out and the map load didn't throw any errors.

Then I tested loading and saving a ddrace map I didn't notice any gamelayer bugs.

Zeta-Hoernchen wrote:
tm = Teemap("myMap.map")
tm.layer[0].name = "foobar"
tm.save("myMap.map")

where layer 0 is not a game layer, the Teeworlds client can't open the map anymore.

Can't reproduce this bug using ctf1 either

15

Re: TeeworldsMapLib

Okay, 3. and 4. seem to only apply for DDRace maps too. :S
But the Error with loading newer DDRace maps i get is:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/local/lib/python2.7/dist-packages/tml-0.2.1-py2.7.egg/tml/tml.py", line 36, in __init__
    self._load(map_path)
  File "/usr/local/lib/python2.7/dist-packages/tml-0.2.1-py2.7.egg/tml/tml.py", line 121, in _load
    datafile = DataFileReader(map_path)
  File "/usr/local/lib/python2.7/dist-packages/tml-0.2.1-py2.7.egg/tml/datafile.py", line 87, in __init__
    author = decompress(self.get_compressed_data(f, author))[:-1]
  File "/usr/local/lib/python2.7/dist-packages/tml-0.2.1-py2.7.egg/tml/datafile.py", line 301, in get_compressed_data
    size = self._get_compressed_data_size(index)
  File "/usr/local/lib/python2.7/dist-packages/tml-0.2.1-py2.7.egg/tml/datafile.py", line 297, in _get_compressed_data_size
    return self.data_offsets[index+1] - self.data_offsets[index]
TypeError: cannot concatenate 'str' and 'int' objects

Maybe "index" is a string here...

16

Re: TeeworldsMapLib

It seems like that https://github.com/erdbeere/tml/ has some known bugs which have been fixed in the repository of Sushitee. Additionally the mapinfo item in tml isn't up to date or just wrong (their is an attribute named 'settings'). I removed it and pushed that stuff together on my own repo:https://github.com/east/tml.git

Could you test this version?

17

Re: TeeworldsMapLib

Hmm, did not fully test it yet, but i have built a 1605x1605 maze map. smile Play it on www.clan-nut.de big_smile