Skip to content

"RuntimeError: A parent directory must be specified when using object templates." #82

Closed
@mothnox

Description

@mothnox

Attempting to open a map as described in the readme generates this error message. The full traceback is as follows:
Traceback (most recent call last): File "/home/moth/programming/mississippi-mayhem/src/tools/mapconv/mapconv.py", line 102, in <module> ConvertArea(area_name, input_dir, output_dir) File "/home/moth/programming/mississippi-mayhem/src/tools/mapconv/mapconv.py", line 72, in ConvertArea maps = CollectMaps(src_dir / area_name) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/home/moth/programming/mississippi-mayhem/src/tools/mapconv/mapconv.py", line 64, in CollectMaps _map = pytiled_parser.parse_map(p) ^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/home/moth/.local/lib/python3.12/site-packages/pytiled_parser/parser.py", line 30, in parse_map return tmx_map_parse(file) # type: ignore ^^^^^^^^^^^^^^^^^^^ File "/home/moth/.local/lib/python3.12/site-packages/pytiled_parser/parsers/tmx/tiled_map.py", line 40, in parse tilesets[int(raw_tileset.attrib["firstgid"])] = parse_tmx_tileset( ^^^^^^^^^^^^^^^^^^ File "/home/moth/.local/lib/python3.12/site-packages/pytiled_parser/parsers/tmx/tileset.py", line 206, in parse tiles[int(tile_element.attrib["id"])] = _parse_tile( ^^^^^^^^^^^^ File "/home/moth/.local/lib/python3.12/site-packages/pytiled_parser/parsers/tmx/tileset.py", line 92, in _parse_tile tile.objects = parse_layer(object_element) ^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/home/moth/.local/lib/python3.12/site-packages/pytiled_parser/parsers/tmx/layer.py", line 372, in parse return _parse_object_layer(raw_layer, parent_dir) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/home/moth/.local/lib/python3.12/site-packages/pytiled_parser/parsers/tmx/layer.py", line 277, in _parse_object_layer objects.append(parse_object(object_, parent_dir)) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/home/moth/.local/lib/python3.12/site-packages/pytiled_parser/parsers/tmx/tiled_object.py", line 266, in parse raise RuntimeError( RuntimeError: A parent directory must be specified when using object templates.

I noticed that most functions in this traceback accept an optional path parameter. However, on line 92 of tileset.py, parse_layer is called without passing along the path that was passed to _parse_tile. Changing it to also pass the path appears to fix it, though I haven't yet tested this further.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions