[feat] global scripts

This commit is contained in:
kwaroran
2023-05-25 21:52:38 +09:00
parent 4aef0363f4
commit f79d3c66e6
6 changed files with 56 additions and 5 deletions

View File

@@ -245,6 +245,12 @@ export function setDatabase(data:Database){
data: []
}]
}
if(checkNullish(data.loreBookPage) || data.loreBook.length < data.loreBookPage){
data.loreBookPage = 0
}
if(checkNullish(data.globalscript)){
data.globalscript = []
}
changeLanguage(data.language)
@@ -474,6 +480,8 @@ export interface Database{
token:string,
model:string
}
globalscript: customscript[]
}
interface hordeConfig{

View File

@@ -1,6 +1,6 @@
import { get } from "svelte/store";
import { CharEmotion, selectedCharID } from "../stores";
import type { character } from "../database";
import { DataBase, type character } from "../database";
const dreg = /{{data}}/g
@@ -11,7 +11,9 @@ export function processScript(char:character, data:string, mode:ScriptMode){
}
export function processScriptFull(char:character, data:string, mode:ScriptMode){
let db = get(DataBase)
let emoChanged = false
const scripts = char.customscript.concat(db.globalscript ?? [])
for (const script of char.customscript){
if(script.type === mode){
const reg = new RegExp(script.in,'g')