|
@@ -7,6 +7,7 @@ import path from "path";
|
|
import defaultProcess from "./src/defaultProcess.js";
|
|
import defaultProcess from "./src/defaultProcess.js";
|
|
import npcInit from "./src/npcInit.js";
|
|
import npcInit from "./src/npcInit.js";
|
|
import skillDefinitions from "./src/skillDefinitions.js";
|
|
import skillDefinitions from "./src/skillDefinitions.js";
|
|
|
|
+import wardrobeItems from "./src/wardrobeItems.js";
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@@ -64,20 +65,32 @@ function convertFile(task){
|
|
//#endregion
|
|
//#endregion
|
|
|
|
|
|
var convertMode = "default";
|
|
var convertMode = "default";
|
|
-
|
|
|
|
- if(qsp2twOptions.startsWith("!! QSRC2TW_module")){
|
|
|
|
|
|
+ var convertModeOptions = {};
|
|
|
|
+ /*if(qsp2twOptions.startsWith("!! QSRC2TW_module")){
|
|
convertMode = qsp2twOptions.trim().split(" ").toReversed()[0];
|
|
convertMode = qsp2twOptions.trim().split(" ").toReversed()[0];
|
|
|
|
+ }*/
|
|
|
|
+ const modeLookupRegex = /\s*!!\s*QSRC2TW_module\s+(\w+)(\s+{[^}]+})?/;
|
|
|
|
+ let modeLookupResult;
|
|
|
|
+ try{
|
|
|
|
+ if(modeLookupResult = modeLookupRegex.exec(qsp2twOptions)){
|
|
|
|
+ convertMode = modeLookupResult[1];
|
|
|
|
+ if(modeLookupResult[2])
|
|
|
|
+ convertModeOptions = JSON.parse(modeLookupResult[2]);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ catch(e){
|
|
|
|
+ console.log(e.toString());
|
|
}
|
|
}
|
|
-
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
* Return value is Array [TwineCode, TSCode]. TwineCode must not be null.
|
|
* Return value is Array [TwineCode, TSCode]. TwineCode must not be null.
|
|
*/
|
|
*/
|
|
- var convertFunction = (code)=>[null,null];
|
|
|
|
|
|
+ var convertFunction = (code,options)=>[null,null];
|
|
switch (convertMode) {
|
|
switch (convertMode) {
|
|
- case "default": convertFunction = (code) => [defaultProcess(code),null]; break;
|
|
|
|
- case "npcInit": convertFunction = (code) => npcInit(code); break;
|
|
|
|
- case "stat_sklattrib_lvlset": convertFunction = (code) => skillDefinitions(code); break;
|
|
|
|
|
|
+ case "default": convertFunction = (code,options) => [defaultProcess(code),null]; break;
|
|
|
|
+ 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;
|
|
default:
|
|
default:
|
|
console.warn("Unreckognized Convert Mode");
|
|
console.warn("Unreckognized Convert Mode");
|
|
break;
|
|
break;
|
|
@@ -93,7 +106,7 @@ function convertFile(task){
|
|
if(!options.verboseErrors)
|
|
if(!options.verboseErrors)
|
|
console = {log:(...args)=>{}, debug: (...args)=>{},warn:(...args)=>{}, error: (...args)=>{}};
|
|
console = {log:(...args)=>{}, debug: (...args)=>{},warn:(...args)=>{}, error: (...args)=>{}};
|
|
try{
|
|
try{
|
|
- [twineCodeRaw,tsCodeRaw] = convertFunction(data);
|
|
|
|
|
|
+ [twineCodeRaw,tsCodeRaw] = convertFunction(data,convertModeOptions);
|
|
}
|
|
}
|
|
catch(e){
|
|
catch(e){
|
|
throw e;
|
|
throw e;
|
|
@@ -102,7 +115,7 @@ function convertFile(task){
|
|
console = defaultConsole;
|
|
console = defaultConsole;
|
|
}
|
|
}
|
|
if(!twineCodeRaw){
|
|
if(!twineCodeRaw){
|
|
- console.error("Twine Code must be generated by every converMode");
|
|
|
|
|
|
+ console.error("Twine Code must be generated by every convertMode");
|
|
return [2,"Invalid convertFunction"];
|
|
return [2,"Invalid convertFunction"];
|
|
}else{
|
|
}else{
|
|
twineCode = twineCodeRaw.split('\n')
|
|
twineCode = twineCodeRaw.split('\n')
|