From 9387caf1e412f0771ecaa5bf506727cda0a4f5f4 Mon Sep 17 00:00:00 2001 From: Jesusaves Date: Thu, 23 Apr 2020 12:34:57 -0300 Subject: Add support to dest_map="self" and dest_map="slide" They'll create a slide object instead of a warp object. --- hercules/tmx_converter.py | 23 ++++++++++++++++------- 1 file changed, 16 insertions(+), 7 deletions(-) diff --git a/hercules/tmx_converter.py b/hercules/tmx_converter.py index 611abee..3264797 100755 --- a/hercules/tmx_converter.py +++ b/hercules/tmx_converter.py @@ -372,13 +372,22 @@ class ContentHandler(xml.sax.ContentHandler): elif isinstance(obj, Warp): if (obj.npc_id == u'WARP'): obj_name = "#%s_%s_%s" % (self.base, obj.x, obj.y) - self.warps.write( - SEPARATOR.join([ - '%s,%d,%d,0\t' % (self.base, obj.x, obj.y), - 'warp\t', - '%s\t%s,%s,%s,%d,%d\n' % (obj_name, obj.w, obj.h, obj.dest_map, obj.dest_x, obj.dest_y), - ]) - ) + if (obj.dest_map.lower() in ["slide", "self"]): + self.warps.write( + SEPARATOR.join([ + '%s,%d,%d,0\t' % (self.base, obj.x, (obj.y)), + '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), + ]) + ) + else: + self.warps.write( + SEPARATOR.join([ + '%s,%d,%d,0\t' % (self.base, obj.x, obj.y), + 'warp\t', + '%s\t%s,%s,%s,%d,%d\n' % (obj_name, obj.w, obj.h, obj.dest_map, 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) -- cgit v1.2.3-70-g09d2