From aba80667c8f2bc8b68cd025fa25a0f91dbc4c8e8 Mon Sep 17 00:00:00 2001 From: kwaroran Date: Sun, 30 Jun 2024 23:11:37 +0900 Subject: [PATCH] fix: add editdisplay limit --- src/ts/process/lua.ts | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/src/ts/process/lua.ts b/src/ts/process/lua.ts index fad93b38..ff450d47 100644 --- a/src/ts/process/lua.ts +++ b/src/ts/process/lua.ts @@ -16,6 +16,7 @@ let luaFactory:LuaFactory let luaEngine:LuaEngine let lastCode = '' let LuaSafeIds = new Set() +let LuaEditDisplayIds = new Set() let LuaLowLevelIds = new Set() export async function runLua(code:string, arg:{ @@ -45,13 +46,13 @@ export async function runLua(code:string, arg:{ } luaEngine = await luaFactory.createEngine() luaEngine.global.set('setChatVar', (id:string,key:string, value:string) => { - if(!LuaSafeIds.has(id)){ + if(!LuaSafeIds.has(id) && !LuaEditDisplayIds.has(id)){ return } setVar(key, value) }) luaEngine.global.set('getChatVar', (id:string,key:string) => { - if(!LuaSafeIds.has(id)){ + if(!LuaSafeIds.has(id) && !LuaEditDisplayIds.has(id)){ return } return getVar(key) @@ -291,9 +292,14 @@ export async function runLua(code:string, arg:{ lastCode = code } let accessKey = v4() - LuaSafeIds.add(accessKey) - if(lowLevelAccess){ - LuaLowLevelIds.add(v4()) + if(mode === 'editDisplay'){ + LuaEditDisplayIds.add(accessKey) + } + else{ + LuaSafeIds.add(accessKey) + if(lowLevelAccess){ + LuaLowLevelIds.add(v4()) + } } let res:any try {