diff options
author | Jesusaves <cpntb1@ymail.com> | 2018-10-28 13:54:44 -0300 |
---|---|---|
committer | Jesusaves <cpntb1@ymail.com> | 2018-10-28 14:32:05 -0300 |
commit | 13e1aaa2de7ab15f5673c038240fd097c5565ac9 (patch) | |
tree | 7d55ca9cfbdafa9a7eecc2a2a1e0c46f320d8673 /hercules | |
parent | e81cf202a7388e4ce3ccbe95206383deef1bff7f (diff) | |
download | tools-13e1aaa2de7ab15f5673c038240fd097c5565ac9.tar.gz tools-13e1aaa2de7ab15f5673c038240fd097c5565ac9.tar.bz2 tools-13e1aaa2de7ab15f5673c038240fd097c5565ac9.tar.xz tools-13e1aaa2de7ab15f5673c038240fd097c5565ac9.zip |
Introducing the SLIDE object type!
Diffstat (limited to 'hercules')
-rwxr-xr-x | hercules/tmx_converter.py | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/hercules/tmx_converter.py b/hercules/tmx_converter.py index 62ad589..3b56a7b 100755 --- a/hercules/tmx_converter.py +++ b/hercules/tmx_converter.py @@ -110,6 +110,18 @@ class Warp(Object): def __init__(self): self.npc_id = 'WARP' +class Slide(Object): + __slots__ = ( + 'dest_x', + 'dest_y', + 'npc_id', + 'trigger_x', + 'trigger_y', + 'notes', + ) + other_warp_fields + def __init__(self): + self.npc_id = 'SLIDE' + class ContentHandler(xml.sax.ContentHandler): __slots__ = ( 'locator', # keeps track of location in document @@ -243,6 +255,12 @@ class ContentHandler(xml.sax.ContentHandler): y += h/2 w -= 1 h -= 1 + elif obj_type == 'slide': + self.object = Slide() + x += w/2 + y += h/2 + w -= 1 + h -= 1 else: if obj_type not in other_object_types: print('Unknown object type:', obj_type, file=sys.stderr) @@ -324,6 +342,18 @@ class ContentHandler(xml.sax.ContentHandler): ]) ) self.warp_cnt = True + elif isinstance(obj, Slide): + if (obj.npc_id == u'SLIDE'): + obj_name = "#%s_%s_%s" % (self.base, obj.x, obj.y) + y_offset = int(self.heightmap[((obj.y * self.width) + obj.x)])/2 + self.warps.write( + SEPARATOR.join([ + '%s,%d,%d,0\t' % (self.base, obj.x, (obj.y + y_offset)), + 'script\t', + '%s\tNPC_HIDDEN,%d,%d,{\n\tend;\nOnTouch:\n\tslide %d,%d; end;\n}\n' % (obj_name, obj.w, obj.h, obj.dest_x, obj.dest_y), + ]) + ) + self.warp_cnt = True elif (not obj.npc_id == u'SCRIPT'): obj_name = "#%s_%s_%s" % (self.base, obj.x, obj.y) self.warps.write( |