diff options
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( |