From 951b50be5e42d25ffc9cdbf7ba3e03ef8b0337c0 Mon Sep 17 00:00:00 2001 From: Jesusaves Date: Wed, 24 Jun 2020 00:21:46 -0300 Subject: Switches: Remove the TODO/FIXME. Check if they're already flipped before flipping --- hercules/tmx_converter.py | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/hercules/tmx_converter.py b/hercules/tmx_converter.py index 5de3e1b..55bca23 100755 --- a/hercules/tmx_converter.py +++ b/hercules/tmx_converter.py @@ -471,16 +471,17 @@ class ContentHandler(xml.sax.ContentHandler): self.save_cnt = True elif isinstance(obj, DungeonSwitch): obj_name = "%s_%s_%s" % (self.base, obj.x, obj.y) + status = ifte(obj.enabled, "OFFLINE", "ONLINE") + nstats = ifte(obj.enabled, "ONLINE", "OFFLINE") self.confs.write( SEPARATOR.join([ '\n', - '// FIXME: Either let flip/unflip, or only run once.\n', - '// This could be done with a new attribute ', - 'and checking NPC display when only run once.\n', '%s,%d,%d,0\t' % (self.base, obj.x, (obj.y)), 'script\t', - '#%s\tNPC_SWITCH_%s,{\n\tcallfunc "%s"%s;\n' % (obj_name, ifte(obj.enabled, "OFFLINE", "ONLINE"), obj.callfunc, ifte(obj.args != '', ", %s" % obj.args, "")), - '\tsetnpcdisplay "#%s", NPC_SWITCH_%s;\n\tend;\nOnInit:\n\t.distance=%d;\n}\n' % (obj_name, ifte(obj.enabled, "ONLINE", "OFFLINE"), obj.distance), + '#%s\tNPC_SWITCH_%s,{\n' % (obj_name, status), + '\tif (getnpcclass() == NPC_SWITCH_%s)\n\t\tend;\n' % (nstats), + '\tcallfunc "%s"%s;\n' % (obj.callfunc, ifte(obj.args != '', ", %s" % obj.args, "")), + '\tsetnpcdisplay "#%s", NPC_SWITCH_%s;\n\tend;\nOnInit:\n\t.distance=%d;\n}\n' % (obj_name, nstats, obj.distance), ]) ) self.save_cnt = True -- cgit v1.2.3-70-g09d2