aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJuan J. Martinez <jjm@usebox.net>2022-12-11 10:41:23 +0000
committerJuan J. Martinez <jjm@usebox.net>2022-12-11 10:41:23 +0000
commitfa92e111ab5dfb3f386ad53317fea0103111cfbb (patch)
treeec634258d3391c05b4fe20cedaca4fb65ca8e3e8
parent4f4e4d92c83795bd2283ed7ff7f61e56c583ad9c (diff)
downloadubox-msx-lib-fa92e111ab5dfb3f386ad53317fea0103111cfbb.tar.gz
ubox-msx-lib-fa92e111ab5dfb3f386ad53317fea0103111cfbb.zip
Make Entities layer optional.
It can also be disabled using "visible" flag in tiled. Closes issue #19
-rw-r--r--docs/tools.md2
-rwxr-xr-xtools/map.py12
2 files changed, 11 insertions, 3 deletions
diff --git a/docs/tools.md b/docs/tools.md
index 67b797a..caf67c4 100644
--- a/docs/tools.md
+++ b/docs/tools.md
@@ -88,7 +88,7 @@ This is a map importer to use with [tiled](https://www.mapeditor.org/) JSON form
The map importer supports:
-- **entities**: an object layer describing game entities such as enemies.
+- **entities**: an optional object layer describing game entities such as enemies. If the "visible" property on this layer is set to "false", the layer will be ignored even if present.
- **map**: a tile layer describing the map itself.
#### Map requirements
diff --git a/tools/map.py b/tools/map.py
index 60ef887..476c1cd 100755
--- a/tools/map.py
+++ b/tools/map.py
@@ -220,8 +220,16 @@ def main():
# ents size placeholder 0
out[i] = [size & 0xFF, size >> 8, 0] + out[i]
- entities_layer = find_name(data["layers"], "Entities")
- if len(entities_layer):
+ try:
+ entities_layer = find_name(data["layers"], "Entities")
+ except ValueError:
+ entities_layer = []
+ if not args.quiet:
+ print(
+ "%s: warning: 'Entities' layer not found" % path.basename(sys.argv[0]),
+ file=sys.stderr,
+ )
+ if len(entities_layer) and entities_layer["visible"]:
map_ents = defaultdict(list)
map_ents_w = defaultdict(int)
map_ents_bytes = defaultdict(int)