Stephan Fuchs 2 сар өмнө
parent
commit
e940d53adc

+ 30 - 0
src/wardrobeItemsTypes.js

@@ -0,0 +1,30 @@
+import defaultProcess from "./defaultProcess.js";
+
+export default function wardrobeItemsTypes(code,options){
+    const twineCode = defaultProcess(code);
+
+    let tsCode = 'setup.wardrobeItemVars ??= {};\n';
+
+    const regexes = {
+        'bras': /if (\w+)S\[i\] = metka_bras and \1\[i\] = 1:/gm,
+        'clothes': /if (\w+)\[i\] = 1 and \(\$clothingworntype ! '\1' or clothingwornnumber ! i\):/gm,
+        'coats': /if (\w+)_s\[i\] = coat_loc and \1\[i\] = 1:/gm,
+        'panties': /if (\w+)S\[i\] = metka_panties and \1\[i\] = 1:/gm,
+        'shoes': /if (\w+)_s\[i\] = sloc and \1\[i\] = 1:/gm,
+    };
+
+    let result;
+
+    for(const[type, regex] of Object.entries(regexes)){
+        let i = 0;
+
+        while(result = regex.exec(code)) {
+            if(i++ == 0)
+                tsCode += `setup.wardrobeItemVars['${type}'] ??= [];\n`;
+            tsCode += `setup.wardrobeItemVars['${type}'].push('${result[1]}');\n`;
+        }
+
+    }
+
+    return [twineCode,tsCode];
+}

+ 3 - 1
task_processor.js

@@ -8,6 +8,7 @@ import defaultProcess from "./src/defaultProcess.js";
 import npcInit from "./src/npcInit.js";
 import skillDefinitions from "./src/skillDefinitions.js";
 import wardrobeItems from "./src/wardrobeItems.js";
+import wardrobeItemsTypes from "./src/wardrobeItemsTypes.js";
 
 const thisFilesHash = md5(fs.readFileSync(__filename,{encoding: 'utf8'}));
 
@@ -91,6 +92,7 @@ function convertFile(task){
 			case "npcInit": convertFunction = (code,options) => npcInit(code); break;
 			case "stat_sklattrib_lvlset": convertFunction = (code,options) => skillDefinitions(code); break;
 			case "wardrobeItems": convertFunction = (code,options) => wardrobeItems(code,options); break;
+			case "wardrobeItemsTypes": convertFunction = (code,options) => wardrobeItemsTypes(code,options); break;
 			default:
 				console.warn("Unreckognized Convert Mode");
 				break;
@@ -160,4 +162,4 @@ function convertFile(task){
 
 parentPort.on('message', (task) => {
     parentPort.postMessage(convertFile(task));
-});
+});