Page 1 of 1

Wrap TeeworldsMapLib for me?

Posted: Wed Dec 05, 2018 10:03 am
by d3fault
I want to write a map generator, but I am no good at Python and I'm not willing to learn it. C++ is my language of choice. There exists a TeeworldsMapLib for working with maps, but it's written in Python. It comes with a test app but it's too fancy and does more than I want (that and I can't read Python very good).

I am a mapping noob in general and I don't want to learn maps as they exist today. There's just too much to them and tl;dr. The output of my C++ map generator would just be a 2D array of "ints", where 0 is nothing, 1 is nonhookable, 2 is hookable, 3 is freeze, 4 is deep, etc.... very basic. I don't care about the graphical part of the map one single bit, I play with entities on 24/7 (this tutorial sucks: viewtopic.php?f=16&t=4020 -- and I see it as a bonus that it would troll Oblique). The app should just read a CSV file of ints or some basic text file format, and output a teeworlds map.

It would probably be a simple app for someone who already knows Python, but I can't be bothered to learn Python just for this.

TeeworldsMapLib: https://github.com/timakro/tml

Re: Wrap TeeworldsMapLib for me?

Posted: Wed Dec 05, 2018 10:13 am
by deen
TML is meant if you don't want to use C++ since regular Teeworlds is already in C++ and contains map support obviously. So you can just edit the regular Teeworlds source code for that. See src/tools/map_* in DDNet for example: https://github.com/ddnet/ddnet/tree/master/src/tools

(Also, Python is quite simple if you already know C++.)

Re: Wrap TeeworldsMapLib for me?

Posted: Fri Dec 07, 2018 5:50 am
by d3fault
hmm getting warmer, never saw these tools. compiled dummy_map.cpp and generated a map, but the resulting map is a bit too.... empty... to be of use. it taught me how to create empty layers, but not how to put down any tiles (despite the code mentioning adding 4x tiles, I don't see any when I load the map). map_resave is too abstract to be of use. do any of these tools create a very small but non-empty map? a spawn point, maybe 5x non-hookable ground tiles to walk on, some hookables up in the air, and a finish tile over to the right.

using ddnet source for this was my first instinct a while ago, but I took the wrong approach and tried reading the in-game map editor source xD...

Re: Wrap TeeworldsMapLib for me?

Posted: Fri Dec 07, 2018 8:12 am
by deen
map_compare reads every tile in the map. Instead of reading you could also change them.

Re: Wrap TeeworldsMapLib for me?

Posted: Sun Dec 09, 2018 6:01 am
by d3fault
only changing existing maps would make the map generator pretty limited. I still don't know how to add a tile. I modified map_diff slightly to dump every tile (not just mismatches), but m_Index is almost always 0 and m_Flags is almost always 0 too. m_aName shows more interesting info (Game, Front, Letters, spikes, ground), but still seems like a category of a layer than a tile type (idk tbh). it's also just a string (so maybe just a a description vs. an identifier?). I tried changing the m_Index for the 4x tiles placed on dummy_map...
Tiles[0].m_Index = ENTITY_SPAWN;
Tiles[1].m_Index = TILE_DEATH;
Tiles[2].m_Index = TILE_NOHOOK;
Tiles[3].m_Index = ENTITY_SPAWN;
... but I still didn't spawn nor did I see any tiles whatsoever (also tried ENTITY_SPAWN_RED).
this probably seems very obvious to you, who has spent so much time with the teeworlds source code, but I'm trying to just dive into it part time for fun... don't really want to learn the code base fully because I got better things to do (like stare at a wall). dummy_map builds a minimal loadable map with nothing in it, but maybe in /tools/ there could exist a map_gensimple.cpp that generates a very small map using raw C++ commands... to give map generator writers a starting point. hell I'll submit it myself if I can ever figure this out.

Re: Wrap TeeworldsMapLib for me?

Posted: Fri Jan 03, 2020 7:46 am
by d3fault
Courtesy of Oblique, here's how to use TML to generate a very basic map that you can actually *spawn* in (not just an empty map that's completely useless):

Code: Select all

from tml.tml import Teemap
from tml.items import Group, Tile, TileLayer
from tml.constants import TILEINDEX

t = Teemap()
t.groups.append(Group())
t.groups[0].layers.append(TileLayer(game=True))
t.groups[0].layers[0].tiles[0] = Tile(TILEINDEX['spawn'])
t.groups[0].layers[0].tiles[1] = Tile(TILEINDEX['solid'])
t.save('simple.map')