summaryrefslogtreecommitdiff
path: root/tmx_converter.py
diff options
context:
space:
mode:
authorLed Mitz <smoothshifter@tuta.io>2023-11-29 22:59:32 +0000
committerLed Mitz <smoothshifter@tuta.io>2023-11-29 22:59:32 +0000
commit5f4eb9489c35b8a8ea91fa65989efa89353c53e7 (patch)
treee020e27e14afcbf70a00f28b37b0d1b70b914b58 /tmx_converter.py
parent6984735e4ee369544147c3458759d6863763ea08 (diff)
parent65075aec353b52fae6db430435aeea963b1505b6 (diff)
downloadtools-master.tar.gz
tools-master.tar.bz2
tools-master.tar.xz
tools-master.zip
Merge branch 'tmx_converter_switches' into 'master'HEADstablemaster
switches on/off See merge request legacy/tools!40
Diffstat (limited to 'tmx_converter.py')
-rwxr-xr-xtmx_converter.py24
1 files changed, 13 insertions, 11 deletions
diff --git a/tmx_converter.py b/tmx_converter.py
index 7274b8b..24506c3 100755
--- a/tmx_converter.py
+++ b/tmx_converter.py
@@ -33,6 +33,7 @@ import zlib
dump_all = False # wall of text
check_mobs = True # mob_db.txt
+create_switches_files = False # creates .switches.txt with template npcs for objects of the class switch (only needed for devs when creating quests)
# lower case versions of everything except 'spawn' and 'warp'
other_object_types = set([
@@ -400,17 +401,18 @@ class ContentHandler(xml.sax.ContentHandler):
self.nodes.write('// (no nodes)\n')
# had to move it here else it writes zero size files not sure if its better to check if a written file has zero size and delete it after
- if len(self.switch_objs) > 0:
- with open(posixpath.join(this_map_npc_dir, NPC_SWITCHES), 'w') as switches:
- switches.write('// %s\n' % MESSAGE)
- switches.write('// %s switches\n\n' % self.name)
- for sobjs in sorted(self.switch_objs):
- obj_name = "#%s_%s_%s" % (self.base, sobjs.x, sobjs.y)
- switches.write(
- SEPARATOR.join([
- '%s,%d,%d,0|script|%s|422\n{\n// REPLACE ME\n}\n' % (self.base, sobjs.x, sobjs.y, obj_name),
- ])
- )
+ if create_switches_files:
+ if len(self.switch_objs) > 0:
+ with open(posixpath.join(this_map_npc_dir, NPC_SWITCHES), 'w') as switches:
+ switches.write('// %s\n' % MESSAGE)
+ switches.write('// %s switches\n\n' % self.name)
+ for sobjs in sorted(self.switch_objs):
+ obj_name = "#%s_%s_%s" % (self.base, sobjs.x, sobjs.y)
+ switches.write(
+ SEPARATOR.join([
+ '%s,%d,%d,0|script|%s|422\n{\n// REPLACE ME\n}\n' % (self.base, sobjs.x, sobjs.y, obj_name),
+ ])
+ )
self.imports.write('// Map %s: %s\n' % (self.base, self.name))
self.imports.write('// %s\n' % MESSAGE)