forked from StationeersMods/ExampleMod
-
Notifications
You must be signed in to change notification settings - Fork 0
/
init.sh
79 lines (59 loc) · 2 KB
/
init.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
#!/bin/bash
modname="##MOD_NAME##"
namespace="##MOD_NAMESPACE##"
echo "Enter a Mod name and namespace. Use the format ExampleMod for the name and Example.Mod for the namespace."
echo "Do not use spaces, numbers, or special characters. The project might not be able to load otherwise."
read -p "Enter the mod name (ex: ExampleMod): " replacename
read -p "Enter the mod namespace (ex: Example.Mod): " replacenamespace
mv "Assets/Scenes/ModNameScene.unity" "Assets/Scenes/${replacename}Scene.unity"
input_file="Assets/Scripts/ModName.asmdef.tmpl"
output_file="Assets/Scripts/${replacename}.asmdef"
if [ ! -f "$input_file" ]; then
echo "File $input_file not found!"
exit 1
fi
while IFS= read -r line; do
line="${line//$modname/$replacename}"
line="${line//$namespace/$replacenamespace}"
echo "$line"
done < "$input_file" > "$output_file"
rm "$input_file"
input_file="Assets/Scripts/ModName.cs.tmpl"
output_file="Assets/Scripts/${replacename}.cs"
if [ ! -f "$input_file" ]; then
echo "File $input_file not found!"
exit 1
fi
while IFS= read -r line; do
line="${line//$modname/$replacename}"
line="${line//$namespace/$replacenamespace}"
echo "$line"
done < "$input_file" > "$output_file"
rm "$input_file"
input_file="Assets/Scripts/patches/PrefabPatch.cs.tmpl"
output_file="Assets/Scripts/patches/PrefabPatch.cs"
if [ ! -f "$input_file" ]; then
echo "File $input_file not found!"
exit 1
fi
while IFS= read -r line; do
line="${line//$modname/$replacename}"
line="${line//$namespace/$replacenamespace}"
echo "$line"
done < "$input_file" > "$output_file"
rm "$input_file"
input_file="Assets/About/About.xml.tmpl"
output_file="Assets/About/About.xml"
if [ ! -f "$input_file" ]; then
echo "File $input_file not found!"
exit 1
fi
while IFS= read -r line; do
line="${line//$modname/$replacename}"
line="${line//$namespace/$replacenamespace}"
echo "$line"
done < "$input_file" > "$output_file"
rm "$input_file"
rm "init.bat"
echo "Initialization complete!"
rm "$0"