diff options
author | Juan J. Martinez <jjm@usebox.net> | 2023-07-15 20:58:47 +0100 |
---|---|---|
committer | Juan J. Martinez <jjm@usebox.net> | 2023-07-15 20:58:47 +0100 |
commit | 4b465f9480c848d74f3127638bdce82539cb7604 (patch) | |
tree | c14de076467dc18849de1a73d63e169f3dad80dd /tools | |
parent | 31259bbbcddaeecd50bafd8de1a5f1ef1bd7a8a2 (diff) | |
download | gold-mine-run-4b465f9480c848d74f3127638bdce82539cb7604.tar.gz gold-mine-run-4b465f9480c848d74f3127638bdce82539cb7604.zip |
Check we don't go over the max number of entities
Diffstat (limited to 'tools')
-rwxr-xr-x | tools/map.py | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/tools/map.py b/tools/map.py index 825f307..c959c50 100755 --- a/tools/map.py +++ b/tools/map.py @@ -49,6 +49,13 @@ def main(): parser.add_argument( "--version", action="version", version="%(prog)s " + __version__ ) + parser.add_argument( + "--max-ents", + dest="max_ents", + type=int, + default=None, + help="limit of entities in the map", + ) parser.add_argument("file_json", help="JSON map to convert") parser.add_argument("output", help="object name for the map data") @@ -82,6 +89,10 @@ def main(): # some entities will never change their y coordinate, so sorting them by y # should help the drawing order in the game objs_sorted = sorted(entity_layer["objects"], key=lambda o: o["y"]) + + if args.max_ents and len(objs_sorted) > args.max_ents: + parser.error("Too many entities (limit: %s)" % args.max_ents) + for ent in objs_sorted: try: typ = entity_types.index(ent["name"]) |