-
Notifications
You must be signed in to change notification settings - Fork 1
/
index.js
51 lines (47 loc) · 1.78 KB
/
index.js
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
/* global ngapp, xelib */
registerPatcher({
info: info,
gameModes: [xelib.gmTES5, xelib.gmSSE],
settings: {
label: 'Cell Encounter Levels In Name',
templateUrl: `${patcherPath}/partials/settings.html`,
defaultSettings: {
formulaRangedLeveled: '{name} [{min} ~ {max}]',
formulaDeleveled: '{name} [{min}]',
formulaLeveled: '{name} [{min}+]'
}
},
requiredFiles: [],
getFilesToPatch: function(filenames) {
return filenames;
},
execute: {
process: [{
load: function(plugin, helpers, settings, locals) {
return {
signature: 'CELL',
filter: function(record) {
return xelib.HasElement(record, 'FULL') && xelib.HasElement(record, 'XEZN') && xelib.GetFlag(record, 'DATA', 'Is Interior Cell');
}
}
},
patch: function(record, helpers, settings, locals) {
let name = xelib.FullName(record);
let eczn = xelib.GetLinksTo(record, 'XEZN');
let min = xelib.GetUIntValue(eczn, 'DATA\\Min Level');
let max = xelib.GetUIntValue(eczn, 'DATA\\Max Level');
let formula = settings.formulaLeveled;
if (min < max) {
formula = settings.formulaRangedLeveled;
} else if (min == max) {
formula = settings.formulaDeleveled;
}
name = formula.replace(/{name}/g, name);
name = name.replace(/{min}/g, min);
name = name.replace(/{max}/g, max);
helpers.logMessage(name);
xelib.SetValue(record, 'FULL', name);
}
}]
}
});