Skip to content

Commit 443b515

Browse files
authored
improves updatepaths documentation and minor code (ParadiseSS13#23123)
1 parent 5e7e0f3 commit 443b515

File tree

3 files changed

+402
-22
lines changed

3 files changed

+402
-22
lines changed
File renamed without changes.

tools/UpdatePaths/__main__.py

+13-6
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
# 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
36
from mapmerge2 import frontend
47
from mapmerge2.dmm import *
58

@@ -10,6 +13,7 @@
1013
/turf/open/floor/iron/warningline : /obj/effect/turf_decal {@OLD} , /obj/thing {icon_state = @OLD:name; name = "meme"}
1114
/turf/open/floor/iron/warningline{dir=2} : /obj/thing
1215
/obj/effect/landmark/start/virologist : @DELETE
16+
/mob/living{resize = @ANY} : /mob/living{@OLD; resize = @SKIP}
1317
Syntax for subtypes also exist, to update a path's type but maintain subtypes:
1418
/obj/structure/closet/crate/@SUBTYPES : /obj/structure/new_box/@SUBTYPES {@OLD}
1519
New paths properties:
@@ -22,6 +26,7 @@
2226
Old paths properties:
2327
Will be used as a filter.
2428
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.
2530
"""
2631

2732
default_map_directory = "../../_maps"
@@ -88,7 +93,9 @@ def replace_def(match):
8893
else:
8994
return [match.group(0)]
9095
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":
9299
return [match.group(0)] #does not match current filter, skip the change.
93100
if verbose:
94101
print("Found match : {0}".format(match.group(0)))
@@ -107,7 +114,8 @@ def replace_def(match):
107114
out = new_path
108115

109116
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)
111119
if prop_name == "@OLD":
112120
out_props = dict(old_props)
113121
continue
@@ -116,8 +124,7 @@ def replace_def(match):
116124
continue
117125
if prop_value.startswith("@OLD"):
118126
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]
121128
continue
122129
out_props[prop_name] = prop_value
123130
if out_props:
@@ -184,7 +191,7 @@ def main(args):
184191
if __name__ == "__main__":
185192
prog = __spec__.name.replace('.__main__', '')
186193
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")
188195

189196
parser = argparse.ArgumentParser(prog=prog, description=desc, formatter_class=argparse.RawTextHelpFormatter)
190197
parser.add_argument("update_source", help="update file path / line of update notation")

0 commit comments

Comments
 (0)