From 3f5f8a7f1609d754185cdc9b8c9d03216e9c6d9c Mon Sep 17 00:00:00 2001 From: Ho-spair Date: Wed, 15 May 2024 17:05:30 +0800 Subject: [PATCH] modify [function] processPrompt --- Fk/Pages/RoomLogic.js | 12 ++++++++---- Fk/util.js | 12 ++++++++---- 2 files changed, 16 insertions(+), 8 deletions(-) diff --git a/Fk/Pages/RoomLogic.js b/Fk/Pages/RoomLogic.js index e7cf92aa..0ef6b9a1 100644 --- a/Fk/Pages/RoomLogic.js +++ b/Fk/Pages/RoomLogic.js @@ -497,10 +497,14 @@ function processPrompt(prompt) { raw = raw.replace(/%src/g, luatr(getPhoto(src).general)); if (raw.match("%dest")) raw = raw.replace(/%dest/g, luatr(getPhoto(dest).general)); - if (raw.match("%arg2")) - raw = raw.replace(/%arg2/g, luatr(data[4])); - if (raw.match("%arg")) - raw = raw.replace(/%arg/g, luatr(data[3])); + + if (data.length > 3) { + for (let i = 4; i < data.length; i++) { + raw = raw.replace(new RegExp("%arg" + (i - 2), "g"), data[i]); + } + + raw = raw.replace(new RegExp("%arg", "g"), data[3]); + } return raw; } diff --git a/Fk/util.js b/Fk/util.js index e7f53fa1..064972a3 100644 --- a/Fk/util.js +++ b/Fk/util.js @@ -21,10 +21,14 @@ function processPrompt(prompt) { raw = raw.replace(/%src/g, luatr(getPhoto(src).general)); if (raw.match("%dest")) raw = raw.replace(/%dest/g, luatr(getPhoto(dest).general)); - if (raw.match("%arg2")) - raw = raw.replace(/%arg2/g, luatr(data[4])); - if (raw.match("%arg")) - raw = raw.replace(/%arg/g, luatr(data[3])); + + if (data.length > 3) { + for (let i = 4; i < data.length; i++) { + raw = raw.replace(new RegExp("%arg" + (i - 2), "g"), data[i]); + } + + raw = raw.replace(new RegExp("%arg", "g"), data[3]); + } return raw; }