==COPIED FROM MEGAGLEST BOARD==
I wanted to read megaglest maps so I could use them in other things. So, I wrote this *dirty* python 3 script to read a map into a python dictionary. The dictionary is formatted such that it can be easily written to disk as e.g. a JSON file.
Here's a link if anyone else is interested in reading maps in python:
https://drive.google.com/file/d/190gXUyiuNKR3ITFtN_zF5MFc6Qogca_f/view?usp=sharing- Maps included were made by atze.
- The script no longer requires numpy! It should be completely compatible with cpython3.
- There is example code, commented out, under if __name__ == "__main__":, which demonstrates previewing atze's 6player.mgm map data in matplotlib and saving the map as a JSON object file.
- The original map data is is stored as a flat, 1d array of numbers, but the script converts the flat array into a 2d array in the shape of the map.
The code is very badly written and has the following problems (in descending order of importance):
- Does not support "version 1" maps (glest maps?).
Needs numpy to read map data (unnecessary as performance not an issue + requires extra dependencies).- Code is generally a mess
which leads to memory inefficiencies in various places.
I may fix these problems sometime, or feel free to fix them yourself if you want

.
The code is licensed under the
MIT License.