1
1
# A script and syntax for applying path updates to maps.
2
- import re , os , sys , argparse
2
+ import re
3
+ import os
4
+ import sys
5
+ import argparse
3
6
from mapmerge2 import frontend
4
7
from mapmerge2 .dmm import *
5
8
10
13
/turf/open/floor/iron/warningline : /obj/effect/turf_decal {@OLD} , /obj/thing {icon_state = @OLD:name; name = "meme"}
11
14
/turf/open/floor/iron/warningline{dir=2} : /obj/thing
12
15
/obj/effect/landmark/start/virologist : @DELETE
16
+ /mob/living{resize = @ANY} : /mob/living{@OLD; resize = @SKIP}
13
17
Syntax for subtypes also exist, to update a path's type but maintain subtypes:
14
18
/obj/structure/closet/crate/@SUBTYPES : /obj/structure/new_box/@SUBTYPES {@OLD}
15
19
New paths properties:
22
26
Old paths properties:
23
27
Will be used as a filter.
24
28
property = @UNSET - will apply the rule only if the property is not mapedited
29
+ property = @ANY - will apply the rule when the property is mapedited, regardless of its value.
25
30
"""
26
31
27
32
default_map_directory = "../../_maps"
@@ -88,7 +93,9 @@ def replace_def(match):
88
93
else :
89
94
return [match .group (0 )]
90
95
else :
91
- if old_props [filter_prop ] != old_path_props [filter_prop ] or old_path_props [filter_prop ] == "@UNSET" :
96
+ if old_path_props [filter_prop ] == "@ANY" :
97
+ continue
98
+ elif old_props [filter_prop ] != old_path_props [filter_prop ] or old_path_props [filter_prop ] == "@UNSET" :
92
99
return [match .group (0 )] #does not match current filter, skip the change.
93
100
if verbose :
94
101
print ("Found match : {0}" .format (match .group (0 )))
@@ -107,7 +114,8 @@ def replace_def(match):
107
114
out = new_path
108
115
109
116
out_props = dict ()
110
- for prop_name , prop_value in new_props .items ():
117
+ for prop_name , prop_text in new_props .items ():
118
+ prop_value = str (prop_text )
111
119
if prop_name == "@OLD" :
112
120
out_props = dict (old_props )
113
121
continue
@@ -116,8 +124,7 @@ def replace_def(match):
116
124
continue
117
125
if prop_value .startswith ("@OLD" ):
118
126
params = prop_value .split (":" )
119
- if prop_name in old_props :
120
- out_props [prop_name ] = old_props [params [1 ]] if len (params ) > 1 else old_props [prop_name ]
127
+ out_props [prop_name ] = old_props [params [1 ]] if len (params ) > 1 else old_props [prop_name ]
121
128
continue
122
129
out_props [prop_name ] = prop_value
123
130
if out_props :
@@ -184,7 +191,7 @@ def main(args):
184
191
if __name__ == "__main__" :
185
192
prog = __spec__ .name .replace ('.__main__' , '' )
186
193
if os .name == 'nt' and len (sys .argv ) <= 1 :
187
- print ("usage: drag-and-drop a path script .txt onto `Update_Paths .bat`\n or" )
194
+ print ("usage: drag-and-drop a path script .txt onto `Update Paths .bat`\n or" )
188
195
189
196
parser = argparse .ArgumentParser (prog = prog , description = desc , formatter_class = argparse .RawTextHelpFormatter )
190
197
parser .add_argument ("update_source" , help = "update file path / line of update notation" )
0 commit comments